Skip to main content

A Python library for easy SQl operations

Project description

SQLSimplify Python Library

The SQLSimplify Python library provides a comprehensive and flexible interface for interacting with MySQL databases. It simplifies common database operations such as querying, creating, updating, deleting, backing up, and restoring databases and tables.

Features

  • Fetch and manage databases and tables
  • Create and modify tables and columns
  • Insert, update, and delete rows in tables
  • Backup and restore databases and tables
  • Execute raw SQL queries

Installation

You can install the library using pip:

pip install SQLSimplify

Usage

Importing the Library

import SQLSimplify

Connecting to MySQL

To use the library, create an instance of the SQLSimplify. Connect class by providing the host, username, password, and optionally the database name.

db = SQLSimplify.Connect(host='localhost', username='root', password='yourpassword', database='yourdatabase') 
#database not required for initial connection

Get Class

Fetch Databases

db.get.database()

Fetch Tables in a Database

db.get.tables('yourdatabase')

Create Class

Create a New Table

db.create.table('new_table', 'id INT PRIMARY KEY, name VARCHAR(100), age INT')

Add a Column to a Table

db.create.column('existing_table', 'new_column', 'VARCHAR(255)')

Delete Class

Delete a Table

db.delete.table('table_to_delete')

Delete a Column from a Table

db.delete.column('table_name', 'column_to_delete')

Delete Rows from a Table

db.delete.row('table_name', 'condition')

Update Class

Update Rows in a Table

db.update.row('table_name', {'column1': 'new_value', 'column2': 10}, 'id = 1')

Modify a Column

db.update.column('table_name', 'column_name', 'VARCHAR(255)')

Rename a Table

db.update.table_name('old_table_name', 'new_table_name')

Backup Class

Backup a Database

db.backup.backup_database('/path/to/backup.sql')

Backup a Table

db.backup.backup_table('table_name', '/path/to/table_backup.sql')

Restore a Database

db.backup.restore_database('/path/to/backup.sql')

Restore a Table

db.backup.restore_table('table_name', '/path/to/table_backup.sql')

Query Class

Execute a Raw SQL Query

db.query.execute('SELECT * FROM table_name')

Perform a SELECT Query

results = db.query.select('table_name', 'column1, column2', 'column1 = value')
print(results)

Perform an INSERT Query

db.query.insert('table_name', {'column1': 'value1', 'column2': 'value2'})

Perform an UPDATE Query

db.query.update('table_name', {'column1': 'new_value'}, 'condition')

Perform a DELETE Query

db.query.delete('table_name', 'condition')

Create a Table

db.query.create_table('new_table', 'id INT PRIMARY KEY, name VARCHAR(100)')

Drop a Table

db.query.drop_table('table_name')

Truncate a Table

db.query.truncate_table('table_name')

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sqlsimplify-0.1.tar.gz (8.5 kB view hashes)

Uploaded Source

Built Distribution

SQLSimplify-0.1-py3-none-any.whl (7.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page