rapyd_db
An opinionated lightweight wrapper around various database backend drivers. The wrapper unifies connection lifecycle, audit-trail logging, and streaming across SQL and document stores while staying out of the way of the underlying driver's query semantics.
Supported backends:
| Backend | Driver | Extra |
|---|---|---|
| MySQL / MariaDB | mysqlclient |
pip install "rapyd_db[mysql]" |
| Microsoft SQL Server | pymssql |
pip install "rapyd_db[mssql]" |
| MongoDB | pymongo |
pip install "rapyd_db[mongo]" |
Install
pip install "rapyd_db[mysql,mssql,mongo]"
Quickstart
from rapyd_db.backends.mysql import MySQL
db = MySQL(host="localhost", user="root", password="...")
# fire-and-fetch (default): returns (rows_affected, lastrowid, results)
affected, last_id, rows = db.execute(
"INSERT INTO users(email) VALUES (%s)",
("alice@example.com",),
)
# streaming for large SELECTs (server-side cursor → no MemoryError)
for row in db.execute("SELECT * FROM events", stream=True):
process(row)
Logging
Every execute() mints a UUID and prepends it to log lines so you can
correlate all log records belonging to a single query:
INFO:rapyd_db.backends:f2e47d8... - Connecting to DB
INFO:rapyd_db.backends.mysql:f2e47d8... - Starting executing query at 2026-05-09 09:00:00
INFO:rapyd_db.backends.mysql:f2e47d8... - Query: SELECT * FROM events
INFO:rapyd_db.backends.mysql:f2e47d8... - 2,844,047 row(s) affected in 10 second(s)
INFO:rapyd_db.backends:f2e47d8... - Closed connection to DB
The package logger ships a NullHandler. Configure logging in your application:
import logging
logging.basicConfig(level=logging.INFO)
Mongo example
from rapyd_db.backends.mongo import Mongo
db = Mongo(host="localhost", username="me", password="...")
db.execute(
"insert_many",
[{"emp_no": 1, "salary": 60_000}],
database="hr",
collection="salaries",
)
The first positional after the operation name is forwarded to the underlying
PyMongo collection method. Pass database= and collection= as keyword
arguments. Operations like server_info operate on the client itself and do
not require those.
MSSQL example
from rapyd_db.backends.mssql import MSSQL
db = MSSQL(host="localhost", user="sa", password="...")
affected, _, rows = db.execute("SELECT @@VERSION AS version")
print(rows[0]["version"])
Supported Python versions
Python 3.9, 3.10, 3.11, 3.12, 3.13.
Development
See CONTRIBUTING.md.
Security
See SECURITY.md for vulnerability disclosure.
License
Apache 2.0 — see LICENSE.
Metadata
Release files for rapyd-db 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| rapyd_db-0.1.0.tar.gz | 16.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| rapyd_db-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 35.3 kB
Release files / rapyd_db-0.1.0.tar.gz
| Download URL | rapyd_db-0.1.0.tar.gz |
|---|---|
| Size | 16.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f6aa6a92c64387ed3614057c70f806734547f86598908bd9b8768dca08e81e1d
|
|
BLAKE2b-256 checksum How to use checksums |
664932c4d9cc3ce5e972aa980b716742b5951a30915f12bd0d2e878dc2dc3494
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 10, 2026.
Transparency logRelease files / rapyd_db-0.1.0-py3-none-any.whl
| Download URL | rapyd_db-0.1.0-py3-none-any.whl |
|---|---|
| Size | 19.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e1e011ba91b54cfdd08203f5d6e2e89b65863631242ee2413cd0dbe0f6cbda04
|
|
BLAKE2b-256 checksum How to use checksums |
e149524b2da740ab5b9947e753d727a98241f22797b5ab39a1d80618c06a2344
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 10, 2026.
Transparency log