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

Uploaded Source

File details

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

File metadata

  • Download URL: SqliteOrmMagic-0.0.5.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.5.tar.gz
Algorithm Hash digest
SHA256 b2833ddd51183f290131c93ada8d384c636c3c8c272804b3f6d1652a8946a199
MD5 6712e4d05fda8711f853785d2c40c82b
BLAKE2b-256 21078286cbcfab35d5b7cd0c6ac2b866ae79105705cde40636840b7c226fd299

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