Library to execute query builder
Project description
Database Query Builder
- A library that serves as a means of connecting to a database and executing sql statements.
Installation 😀📚
pip install db_querybuilder
Get started
How to use Database Query Builder
It is very important to make the connection to the database that we are going to use.
New Version updated
-
New updated version 0.2.0
-
Now with Sqlite integration. If you will use the sqlite integration, I invite you to read the official sqlite documentation, to see the types of data that it allows to use.
from db_querybuilder import DatabaseQueryBuilder
class TestUser():
def __init__(self) -> None:
self.id = -1
self.first_name = 'Jhon'
self.last_name = 'Doe'
if __name__ == '__main__':
db = DatabaseQueryBuilder(db_user='root',db_password='',db_database='test',db_port=3306)
# Query to json
query = db.setTable('test_data').query().where(clausule='id',parameter=1).toJson()
print(query)
# Query select
query = db.select(['id','first_name']).from_('test_data').where('email','emaffini0@mlb.com').results()
print(query)
# Insert data with attributes object
user = TestUser()
query = db.insert(table='test_data',object=user)
print(query)
# Intregration with sqlite
# New version with sqlite queries
dbSqlite = DatabaseQueryBuilder(db_database='./db/hmi_creatio', driver= DatabaseDrivers.DRIVER_SQLITE.value)
dbSqlite.setTable('test_data')
query = dbSqlite.createTable(columns = ['id integer primary key autoincrement','name varchar(40)']).insert(fields=['id','name'],values=[1,'Jhon Doe'])
print(query)
query = dbSqlite.select(fields=['id','name']).toJson()
print(query)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
db-querybuilder-0.2.0.tar.gz
(7.3 kB
view details)
Built Distribution
File details
Details for the file db-querybuilder-0.2.0.tar.gz
.
File metadata
- Download URL: db-querybuilder-0.2.0.tar.gz
- Upload date:
- Size: 7.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d8d3c420a246bf9c1b55d289390364d629e1a5449f3a82c51667a5df3f56f78 |
|
MD5 | 3ae6b3fe71c647e546f3488120b59cab |
|
BLAKE2b-256 | e8db5dd275351bb22e4372fcdd26c566ec25cfc0401f3aeb9fec24815ba2cf65 |
File details
Details for the file db_querybuilder-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: db_querybuilder-0.2.0-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f3c80927d96cd4cc4b2f6f29d59b910469a2f7ceb929530b8b92963171370960 |
|
MD5 | bebfff162e27e2f399cfe3951e81736f |
|
BLAKE2b-256 | 089dab7e22cfeb365059eb6da331fa766920c10dde25e3b2287699560a14ef6b |