Ngiridb
ngiridb gives you simple asyncio support for a range of databases.
It allows you to make queries using the powerful SQLAlchemy Core expression language, and provides support for PostgreSQL, MySQL, and SQLite.
ngiridb is suitable for integrating against any async Web framework, such as Ngiriapi, Sanic, Responder, Quart, aiohttp, Tornado, or FastAPI.
Documentation: https://www.ngiri.co.tz/ngiridb/
Requirements: Python 3.7+
Installation
$ pip install ngiridb
Database drivers supported are:
You can install the required database drivers with:
$ pip install ngiridb[asyncpg]
$ pip install ngiridb[aiopg]
$ pip install ngiridb[aiomysql]
$ pip install ngiridb[asyncmy]
$ pip install ngiridb[aiosqlite]
Note that if you are using any synchronous SQLAlchemy functions such as engine.create_all() or alembic migrations then you still have to install a synchronous DB driver: psycopg2 for PostgreSQL and pymysql for MySQL.
Quickstart
For this example we'll create a very simple SQLite database to run some queries against.
$ pip install ngiridb[aiosqlite]
$ pip install ipython
We can now run a simple example from the console.
Note that we want to use ipython here, because it supports using await
expressions directly from the console.
# Create a database instance, and connect to it.
from ngiridb import Database
database = Database('sqlite+aiosqlite:///example.db')
await database.connect()
# Create a table.
query = """CREATE TABLE HighScores (id INTEGER PRIMARY KEY, name VARCHAR(100), score INTEGER)"""
await database.execute(query=query)
# Insert some data.
query = "INSERT INTO HighScores(name, score) VALUES (:name, :score)"
values = [
{"name": "Daisy", "score": 92},
{"name": "Neil", "score": 87},
{"name": "Carol", "score": 43},
]
await database.execute_many(query=query, values=values)
# Run a database query.
query = "SELECT * FROM HighScores"
rows = await database.fetch_all(query=query)
print('High Scores:', rows)
Check out the documentation on making database queries for examples of how to start using ngiridb together with SQLAlchemy core expressions.
Metadata
Release files for ngiridb 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ngiridb-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for ngiridb-0.0.1-py3-none-any.whl |
Release files / ngiridb-0.0.1-py3-none-any.whl
| Download URL | ngiridb-0.0.1-py3-none-any.whl |
|---|---|
| Size | 22.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ee2669a3580c01d45afcbe6f767046c82c0ea080276790c21550b66a818b2809
|
|
BLAKE2b-256 checksum How to use checksums |
5337ea47cfa8b2f470a7d5fb104f2947da1dc7104c09842e4d113d0c19682722
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.10
|
Security for ngiridb 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.