a Database Wrapper for Redis and MySQL
Project description
a Database Wrapper for Redis and MySQL
from DBService import MysqlService
mysql_server = MysqlService(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD, MYSQL_PORT, MYSQL_DB)
# query
mysql_server.query("SELECT * FROM TABLE")
# execute
mysql_server.execute("UPDATE from TABLES SET a = 55 WHERE id = 1")
# transaction
mysql_server.query(["UPDATE from TABLES SET a = 55 WHERE id = 1","UPDATE from TABLES SET a = 545 WHERE id = 2"])
from DBService import RedisService
redis_server = RedisService("redis://:user@host:port/db")
from DBService import PgsqlService
pgsql_server = PgsqlService(PGSQL_HOST, PGSQL_USER, PGSQL_PASSWORD, PGSQL_PORT, PGSQL_DB)
# query
pgsql_server.query("SELECT * FROM TABLE")
# execute
pgsql_server.execute("UPDATE from TABLES SET a = 55 WHERE id = 1")
# transaction
pgsql_server.query(["UPDATE from TABLES SET a = 55 WHERE id = 1","UPDATE from TABLES SET a = 545 WHERE id = 2"])
also support async,use them just add 'await'
from DBService import AsyncRedisService,AsyncMysqlService,AsyncPgsqlService
redis_server = AsyncRedisService("redis://:user@host:port/db")
mysql_server = AsyncMysqlService(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD, MYSQL_PORT, MYSQL_DB)
pgsql_server = AsyncPgsqlService(PGSQL_HOST, PGSQL_USER, PGSQL_PASSWORD, PGSQL_PORT, PGSQL_DB)
# or pgsql_server = AsyncPgsqlService(dsn="postgresql://username:password@localhost:5432/mydatabase")
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
dbservice-2.0.8.tar.gz
(13.3 kB
view hashes)
Built Distribution
dbservice-2.0.8-py3-none-any.whl
(14.4 kB
view hashes)
Close
Hashes for dbservice-2.0.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 727f739bde1dd019801988e8d71db2d04adb7a3d5a0b609942cc201f198f016e |
|
MD5 | b9123f36c92e7542b9143d4c48a74ad7 |
|
BLAKE2b-256 | 73f1f96b513c302bcf1b2e7cc739878bb7dae93f5b9b7c1850b40a876bf20612 |