Youtube Logo Sqlazo Author - Santiago Rivera Marin

SQLAZO

Sqlazo Author - Santiago Rivera Marin
Sponsor me on GitHub Buy me a coffee button
PyPI Downloads PyPI - Version PyPI - Python Version Static Badge GitHub License

"Sqlazo" is a module that allows you to manage basic procedures in a "sqlite3" database in PYTHON.

Before running any command from this module, I recommend you check these two modules first:

Initialisation

To begin, its use would start with an instance of the Database class, which takes the following parameters as arguments:

# Example of initialisation
from sqlazo import Database

db = Database('test.db', False)
# This will create a test.db file ready for use...

Available Public Methods:

# Columns with their configurations
cols = ['id INTEGER PRIMARY KEY', 'name TEXT NOT NULL', 'age INTEGER NOT NULL']
# Execute "query" (Create table)
db.create_table('user', cols)
# Execute "query" (Validate table)
# Returns a boolean indicating the table's existence
db.table_exists('user')
db.insert_data(['Santiago', 19], ['name', 'age'], 'user')
db.get_data_all('user')
# If the third parameter exists, only those columns will be considered in the "query"
# It will return records that meet the condition and only return the "name" column
# select name from user where id < 3
db.get_data_where('user', 'id < 3', 'name')

# If *args do not exist, it is understood that all columns will be selected
# Returns records valid for the condition and all columns
# select * from user where id < 3*
db.get_data_where('user', 'id < 3')
# Delete underage users
db.delete_data('user', 'age < 18')
# Close connection with the database
db.close()

Private Methods 🔏

# For internal use only

Full usage example:


    # Example of initialisation
    from sqlazo import Database

    db = Database('test.db', False)

    # Columns with their configurations
    cols = ['id INTEGER PRIMARY KEY', 'name TEXT NOT NULL', 'age INTEGER NOT NULL']
    # Execute "query" (Create table)
    db.create_table('user', cols)
    db.insert_data(['Santiago', 19], ['name', 'age'], 'user')

    dataAll = db.get_data_all('user')

    # If the third parameter exists, only those columns will be considered in the "query"
    # It will return records that meet the condition and only return the "name" column
    # select name from user where id < 3
    data_where1 = db.get_data_where('user', 'id < 3', 'name')

    # If *args do not exist, it is understood that all columns will be selected
    # Returns records valid for the condition and all columns
    # select * from user where id < 3*
    data_where12 = db.get_data_where('user', 'id < 3')

    # Delete underage users
    db.delete_data('user', 'age < 18')

    # Close connection with the database
    db.close()