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.4.tar.gz (3.8 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: SqliteOrmMagic-0.0.4.tar.gz
  • Upload date:
  • Size: 3.8 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.4.tar.gz
Algorithm Hash digest
SHA256 3103dea8918207157dded0ee95c2fd4b0c1073e75fac9236489c66cf78524751
MD5 e8bb5e248dcb1d102966b9af56f81cc4
BLAKE2b-256 42f6ee96b7231a84e1ceeb2ccfada4d98f1e29fa2ee11ae872fdc52b467afddb

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