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

Uploaded Source

File details

Details for the file sqliteormmagic-0.0.7.tar.gz.

File metadata

  • Download URL: sqliteormmagic-0.0.7.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.7.tar.gz
Algorithm Hash digest
SHA256 00696c2e67dd1716a0eb63b99f32e9f77d989139e83ef43a2fe555ca7a7c3618
MD5 06df4ec2999783e6f8c9f0e7c48bf641
BLAKE2b-256 715c3bdc24442c808c26bc658391132eace4e083dd9d03fb54c46c659757530e

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