An opinionated lightweight wrapper around various DB backend drivers.
Project description
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.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rapyd_db-0.1.0.tar.gz.
File metadata
- Download URL: rapyd_db-0.1.0.tar.gz
- Upload date:
- Size: 16.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f6aa6a92c64387ed3614057c70f806734547f86598908bd9b8768dca08e81e1d
|
|
| MD5 |
5f47496405b86b47d69502c71ca16d98
|
|
| BLAKE2b-256 |
664932c4d9cc3ce5e972aa980b716742b5951a30915f12bd0d2e878dc2dc3494
|
Provenance
The following attestation bundles were made for rapyd_db-0.1.0.tar.gz:
Publisher:
publish.yml on karthicraghupathi/rapyd_db
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rapyd_db-0.1.0.tar.gz -
Subject digest:
f6aa6a92c64387ed3614057c70f806734547f86598908bd9b8768dca08e81e1d - Sigstore transparency entry: 1488117973
- Sigstore integration time:
-
Permalink:
karthicraghupathi/rapyd_db@2336d9213e7b176699f088500766dc87a4d3a00f -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/karthicraghupathi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2336d9213e7b176699f088500766dc87a4d3a00f -
Trigger Event:
push
-
Statement type:
File details
Details for the file rapyd_db-0.1.0-py3-none-any.whl.
File metadata
- Download URL: rapyd_db-0.1.0-py3-none-any.whl
- Upload date:
- Size: 19.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e1e011ba91b54cfdd08203f5d6e2e89b65863631242ee2413cd0dbe0f6cbda04
|
|
| MD5 |
d018aa929f3137f9558fef5154792b25
|
|
| BLAKE2b-256 |
e149524b2da740ab5b9947e753d727a98241f22797b5ab39a1d80618c06a2344
|
Provenance
The following attestation bundles were made for rapyd_db-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on karthicraghupathi/rapyd_db
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rapyd_db-0.1.0-py3-none-any.whl -
Subject digest:
e1e011ba91b54cfdd08203f5d6e2e89b65863631242ee2413cd0dbe0f6cbda04 - Sigstore transparency entry: 1488117987
- Sigstore integration time:
-
Permalink:
karthicraghupathi/rapyd_db@2336d9213e7b176699f088500766dc87a4d3a00f -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/karthicraghupathi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2336d9213e7b176699f088500766dc87a4d3a00f -
Trigger Event:
push
-
Statement type: