A lightweight db tools for sql.
Project description
dbtool
A lightweight db tools for sql.
pip install dbtool
# sqlite3 ....
db = dbtool.DB('sqlite', database=':memory:')
# sql
db.execute(sql)
db.execute_fetchone(sql)
db.execute_count(sql)
db.execute_cursor(sql)
db.execute_many(sql)
db.execute_script(sql)
db.execute_file(file)
# crud
db.insert(dict, table='user')
db.update(dict, table='user', id_name='id')
db.delete_by_id(1, table='user', id_name='id')
db.find_by_id(1, table='user', id_name='id')
db.find('user', type=0)
db.find_one('user', id=1)
db.find_count('user', type=0)
# transactions
with db.transaction():
db.execute(sql1)
# example mysql
db_config = {
'host': '127.0.0.1',
'port': 3306,
'database': 'test',
'user': 'root',
'password': '123456',
'client_flag': CLIENT.MULTI_STATEMENTS,
}
db = dbtool.DB('mysql', mincached=1, maxconnections=20, **db_config)
db vs driver
- sqlite - sqlite3
- mysql - pymysql
- postgresql - psycopg2
- sqlserver - pymssql
connections pool args: https://webwareforpython.github.io/DBUtils/main.html#pooleddb-pooled-db
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
dbtool-0.0.4.tar.gz
(4.4 kB
view details)
Built Distribution
File details
Details for the file dbtool-0.0.4.tar.gz
.
File metadata
- Download URL: dbtool-0.0.4.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f16ac948ae2e5e61f83579661ba9f34e736fb4aebae86e2416bc735ad1c8d0f |
|
MD5 | a8effe5130eac3c60bda98161983916c |
|
BLAKE2b-256 | 87490f27731bcbf5d8af5bbf20566cc6b124cdd988a980ea5dab2861e932dbed |
File details
Details for the file dbtool-0.0.4-py3-none-any.whl
.
File metadata
- Download URL: dbtool-0.0.4-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2a22ad482e7637ed47532ce7a988606739d89b68adad05a66fe6800cd2143e6d |
|
MD5 | 2198b58add2c8e812b4fe3b85adcc19d |
|
BLAKE2b-256 | a422e74539ebe73743f8deadbe336bdb1ba9d1d7ad57ab9d1b928f92545b2177 |