Skip to main content

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

Project description

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

Project details


Download files

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

Source Distribution

SqliteOrmMagic-0.0.6.tar.gz (4.2 kB view details)

Uploaded Source

File details

Details for the file SqliteOrmMagic-0.0.6.tar.gz.

File metadata

  • Download URL: SqliteOrmMagic-0.0.6.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for SqliteOrmMagic-0.0.6.tar.gz
Algorithm Hash digest
SHA256 84a604d17401f1d753dd528ef4d2cf92c0903362241b3b28636685fe6ecfa221
MD5 97f7765ee274096413e7019f50c3889d
BLAKE2b-256 9fadb6ba9af76bf2e3261cb78c7121f366e48f6f0f90312fccb4cb2bc24a7e01

See more details on using hashes here.

Supported by

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