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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file sqlsimplify-0.1.tar.gz.

File metadata

  • Download URL: sqlsimplify-0.1.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.6

File hashes

Hashes for sqlsimplify-0.1.tar.gz
Algorithm Hash digest
SHA256 fc0ca5fc68ac9ad445196ca8c78144d6b218eb77e7b0c68954bb2ac13da993be
MD5 309fb2c0448e14cd49ab040af89531ba
BLAKE2b-256 fbb0e0f9e19edfed7a417053d3aa7e43d1cfc29e39323fcca4e125ba3dc09ec5

See more details on using hashes here.

File details

Details for the file SQLSimplify-0.1-py3-none-any.whl.

File metadata

  • Download URL: SQLSimplify-0.1-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.6

File hashes

Hashes for SQLSimplify-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ee17e89882c6050d091553721908cd4f4358b3fc56fd0f0025bee4703e0a48f7
MD5 52d7978dce8befca36eab67b57841872
BLAKE2b-256 66fd6709cce6eec77fd066aa4df62921bdf5132a23591e1dbde9e5ca550390af

See more details on using hashes here.

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