Skip to content

Facilitates the complex syntax of SQL queries through the use of standard commands for reading / writing to the SQlite3 database in Python program

License

Notifications You must be signed in to change notification settings

Practic1984/SqliteOrmMagic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SqliteOrmMagic

Facilitates the complex syntax of SQL queries through the use of standard commands for reading / writing to the SQlite3 database in Python program


For example:

Import
from SqliteOrmMagic import SQLiteDB

Importing the library:
import SqliteOrmMagic as som

Create an instance of the class:
db=som.SQLiteDB('users.db')

Create a table:
db.create_table(table, list_query_params)
table: str table name
list_query_params: list query parameters
An example of how column names are passed to a table by a list of tuples:
list_query_params = [
('from_user_id', 'INTEGER UNIQUE'), must be unique values ​​here
('from_user_username', 'TEXT'),
('from_user_firstname', 'TEXT'),
('regtime', 'INTEGER')
]


Search in a column by cell value
res = db.find_elements_in_column(table_name, key_name, column_name)
print(res) # print the search result

Database search function by cell value with column name returns a list of tuples of one table row
table_name: str table name
key_name: str key name
column_name: str column name

Search in a column by a string in a cell
res = db.find_elements_by_keyword(table_name, key_name, column_name)
print(res) # print the search result

Database search function searches for matches in a column line by line returns a list of tuples
table_name: str the name of the table
key_name: str keyword string
column_name: str column name

Insert row with unique value by column
db.ins_unique_row(table_name, list_query_params)
database insertion function unique value with column name if there was a UNIQUE flag when creating a column in a database table
table_name: str table name
list_query_params: list list of tuples of one table row
Parameter List Loading Example
list_query_params = [
('from_user_id', '123'),
('from_user_username', 'vasya'),
('from_user_firstname', 'petrov'),
('regtime', '1234568')
]



Update the value of a cell in a column
db.upd_element_in_column(table_name, upd_par_name, key_par_name, upd_column_name, key_column_name)
database insertion function unique value with column name if there was a UNIQUE flag when creating a column in a database table
database update function by cell value with column name
table_name: str table name
upd_par_name: str name of the parameter to update
key_par_name: str name of the parameter to search
upd_column_name: str name of the column to update
key_column_name: str name of the column to search


all wishes and suggestions can be sent to the author @Practic_old

About

Facilitates the complex syntax of SQL queries through the use of standard commands for reading / writing to the SQlite3 database in Python program

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages