Full power of *asyncpg* with user friendly api of *sqlalchemy.core*
Project description
Corebases
Full power of asyncpg with user friendly api of sqlalchemy.core
Corebases - is async adapter for Sqlalchemy.Core. Interface and code based on encode/databases, but has bit difference. Now supported only asycnpg driver (but It's possible to extend)
Current status - Experimental
Reason for create fork
Install
> pip install corebases
Usage
# Create a database instance, and connect to it.
from corebases import database
database = database('postgres://user:pass@localhost:5432')
await database.connect()
# Insert some data.
query = "INSERT INTO HighScores(name, score) VALUES (:name, :score)"
value = {"name": "Daisy", "score": 92}
with database.transaction() as db:
await db.execute(query=query, value=value)
# Run a database query.
query = "SELECT * FROM HighScores"
rows = await database.fetch_all(query=query)
print('High Scores:', rows)
await database.disconnect()
Difference between encode/databases
Principal is a bit of difference in interface on transactions:
encode/database:
with database.transaction():
await database.execute(query=query, value=value)
corebases:
with database.transaction() as db:
await db.execute(query=query, value=value)
Also, corebases doesn't support methods:
- feach_val
- execute_many
But we can add in the future.
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
corebases-0.2.1.tar.gz
(4.7 kB
view hashes)
Built Distribution
Close
Hashes for corebases-0.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 20da5800f636ddb4217fa965b63f37d748416914a86759362d53d6b2896c6a97 |
|
MD5 | 5e0b3795278ea52f1f98de6c74ffe8c1 |
|
BLAKE2b-256 | 673757f99bb53e2827919c15d5c9a9d26842b0da25e5941814fe7285fa8f5de5 |