Documentation
- class quick_sqlite.QuickSqlite(db_path: str, protect: bool, key: str = '')
Bases:
object
Class to use SQLite3.
- Parameters
db_path (str) – The path to the database.
protect (bool) – If True, the database will be encrypted.
key (str) – The Fernet key to use for encryption.
- add_column(table_name: str, column: Column)
Adds a column to the specified table.
- Parameters
table_name (str) – The name of the table to add the column to.
column (Column) – The column to add. You should use quick_sqlite.Column() class.
- check_column_exists(table_name, column_name) bool
Checks if specified column exists in the specified table.
- Parameters
table_name (str) – Name of the table to check.
column_name (str) – The name of the column to check.
- Returns
True if column exists, False otherwise.
- Return type
bool
- check_table_exists(table_name: str) bool
Checks if specified table exists in the database.
- Parameters
table_name (str) – Name of the table to check.
- Returns
True if table exists, False otherwise.
- Return type
bool
- create_table(table_name: str, columns: list[quick_sqlite.column.Column])
Creates the table with specified name and column name(s).
- Parameters
table_name (str) – The name of the table to create.
columns (list[Column]) – Column class using quick_sqlite.Column() class.
- delete_column(table_name: str, column_name: str)
Deletes a column from the specified table.
- Parameters
table_name (str) – The name of the table to delete the column from.
column_name (str) – The name of the column to delete.
- delete_row(table_name: str, column_name: str, data: str)
Deletes the specified row from the table.
- Parameters
table_name (str) – The name of the table of which you want to delete the data.
column_name (str) – The name of the column of which you want to delete the data.
data (str) – The data of the row to be deleted.
- delete_table(table_name: str)
Deletes the specified table.
- Parameters
table_name (str) – The name of the table to delete.
- fetch_column(table_name: str, column_name: str) list[tuple]
Returns a specified column of the specified table.
- Parameters
table_name (str) – The name of the table of which you want column.
column_name (str) – The name of the column of which you want data.
- Returns
Returns the list containing data of each row in tuples.
- Return type
list[tuple]
- fetch_data(table_name: str, column_name: str, filter_column_name: str, filter_column_data: str, condition: str) tuple[str]
Returns a specified data from a specified column.
- Parameters
table_name (str) – The name of the table of which you want the data.
column_name (str) – The name of the column of which you want the data.
filter_column_name (str) – The name of the column you want to be filtered through.
filter_column_data (str) – The data of the column you want to be filtered through.
condition – Condition to search the data. Available are: =, <, >, <=, >=, <>(not equal). this will look like: {filter_column_name} {condition} {filter_column_data}
- Returns
Returns a tuple consisting of the data of the specified column as string.
- Return type
tuple[str]
- fetch_table(table_name: str, row_limit: Optional[int] = None) list[tuple]
Returns all data of the specified table.
- Parameters
table_name (str) – The name of the table of which you want the data.
row_limit (int) – The number of rows to fetch.
- Returns
Returns the list containing data of each row in tuples.
- Return type
list[tuple]
- insert_data(table_name: str, data: dict)
Inserts the data in the specified column of the specified table.
- Parameters
table_name (str) – The name of the table in which data is to be inserted.
data (dict) – The data dictionary with key as column_name and value as column_value i.e. data
- rename_column(table_name: str, old_column_name: str, new_column_name: str)
Renames a column in the specified table.
- Parameters
table_name (str) – The name of the table to rename the column in.
old_column_name (str) – The name of the column to rename.
new_column_name (str) – The new name of the column.
- rename_table(old_table_name: str, new_table_name: str)
Renames the specified table.
- Parameters
table_name (str) – The name of the table to rename.
old_table_name (str) – The old name of the table.
new_table_name (str) – The new name of the table.
- update_data(table_name: str, data: dict, filter_column_name: str, filter_column_data: str)
Updates the data in the specified column of specified table.
- Parameters
table_name (str) – The name of the table in which data is to be updated.
column_name (str) – The name of the column in which data is to be updated.
data (dict) – The data dictionary with key as column_name and value as column_value i.e. data
filter_column_name (str) – The name of a column to filter the row.
filter_column_data (str) – The data of a column to filter the row.