polydb
One async API for PostgreSQL, MongoDB, SQLite, and MySQL.
Source: https://github.com/Genius740Code/polydb
polydb gives application code a single async API for CRUD, schema, transactions,
and raw-query escape hatches, backed by three adapters (Postgres, Mongo, and a
SQL-generic family covering SQLite + MySQL). Switching backends is a
connection-string change — see the planning document for the full
support matrix and build order.
Current status
Planned, not fully built. Implemented so far (planning doc §1.1 Connection management + §1.2 Create + §1.3 Read):
| Feature | Status |
|---|---|
Database.from_url(url) -> Database — factory resolves every supported scheme to its adapter instance |
✅ Done |
connect() / disconnect() / ping() / async context manager |
✅ Done (SQLite leg; ping returns False instead of raising on an unreachable backend) |
pool_size, timeout query params |
✅ Done — validated at parse time, exposed as db.pool_size / db.timeout; SQLite accepts-and-ignores non-default pool_size with a warning (single-writer file) |
insert_one(collection, doc) → InsertResult |
✅ Done (SQLite leg; inserted_id = rowid) |
insert_many(collection, docs) → InsertManyResult |
✅ Done (SQLite leg; heterogeneous docs fill missing columns with NULL; one commit, all-or-nothing) |
upsert_one(collection, filter, doc) → UpsertResult |
✅ Done (SQLite leg; Mongo-style match-first-row-or-insert semantics — filter fields merge into the inserted row, doc wins on key conflicts) |
find_one(collection, filter) → dict | None |
✅ Done (SQLite leg; full Mongo-shaped filter DSL — $eq/$ne/$gt/$gte/$lt/$lte, $in/$nin, $exists, $regex, $like, $and/$or/$nor/$not) |
find(collection, filter, *, sort, limit, offset) → list[dict] |
✅ Done (SQLite leg; sort takes (field, 1 | -1) pairs) |
count(collection, filter) → int |
✅ Done (SQLite leg) |
exists(collection, filter) → bool |
✅ Done (SQLite leg; short-circuits via LIMIT 1) |
aggregate(collection, pipeline) → list[dict] |
✅ Done (SQLite leg; restricted subset: repeatable $match, then at most one $group ($sum/$avg/$min/$max/$count) / $sort / $limit / $count; anything else raises UnsupportedOperationError) |
| Update, delete, schema, transactions, raw queries | ⬜ Not started |
Filters are compiled by the shared sql_compiler.py into fully parameterized SQL;
column/table names are validated against [A-Za-z_][A-Za-z0-9_]* and quoted.
SQLite quotes identifiers with backticks on purpose — double-quoted unknown
identifiers silently become string literals in SQLite, hiding typos.
Postgres / Mongo / SQL-MySQL legs raise NotImplementedError until their
respective build steps land (see build order §6).
Installation
The PyPI distribution is genius74o-polydb (the plain polydb name is
squatted); the Python package you import is still polydb:
pip install genius74o-polydb # core (no drivers)
pip install "genius74o-polydb[sqlite]" # + a driver, or: postgres / mongo / mysql
pip install "genius74o-polydb[all]" # every driver
Quick start (SQLite — the one working leg)
import asyncio
from polydb import Database
async def main() -> None:
async with Database.from_url("sqlite:///:memory:") as db:
assert await db.ping() is True
asyncio.run(main())
Connecting to other backends
Database.from_url() resolves all supported schemes to their adapter class,
returning an unconnected instance:
| URL scheme | Adapter class | connect() today |
|---|---|---|
postgres:// / postgresql:// |
PostgresAdapter |
NotImplementedError (build step 3) |
mongodb:// / mongodb+srv:// |
MongoAdapter |
NotImplementedError (build step 4) |
sqlite:///... |
SqlAdapter (dialect sqlite) |
✅ live |
mysql:// |
SqlAdapter (dialect mysql) |
NotImplementedError (build step 5) |
Under the hood
- docs/connection.md — connection URL format, adapter resolution, tuning knobs.
- examples/switching_backends.py — one script, three connection strings.
- plan.md — planning document: feature list, DSL spec, build order, testing strategy.
Development
# install dev extras (pytest, pytest-asyncio, drivers)
pip install -e ".[dev]"
# run the test suite from the repo root
PYTHONPATH=src pytest
Branching & releases
All development happens on the development branch; master is release-only.
The publish.yml workflow automates publishing:
| Push to | Tests | Published to | Version |
|---|---|---|---|
development |
✅ gate | TestPyPI | auto <base>.dev<run> (e.g. 0.1.0.dev42) — every commit gets a unique installable version |
master |
✅ gate | PyPI | exactly what's in pyproject.toml |
To cut a release: bump version in pyproject.toml, merge development
into master, and push — PyPI rejects re-uploaded versions, so bump first.
Publishing authenticates with PyPI API tokens stored as GitHub repo secrets (Settings → Secrets and variables → Actions):
| Secret | Where to create it |
|---|---|
TESTPYPI_API_TOKEN |
test.pypi.org → Account settings → API tokens |
PYPI_API_TOKEN |
pypi.org → Account settings → API tokens |
or from the CLI: gh secret set TESTPYPI_API_TOKEN / gh secret set PYPI_API_TOKEN.
Metadata
Release files for genius74o-polydb 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 | Provenance | Actions |
|---|---|---|---|---|
| genius74o_polydb-0.1.0.tar.gz | 47.4 kB | Without provenance | Details for genius74o_polydb-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| genius74o_polydb-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for genius74o_polydb-0.1.0-py3-none-any.whl |
Total release size: 78.0 kB
Release files / genius74o_polydb-0.1.0.tar.gz
| Download URL | genius74o_polydb-0.1.0.tar.gz |
|---|---|
| Size | 47.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8f1369f2a2ac4ff19155e82886e1089886d97aa5700cfa16ba8f34fe948f6dac
|
|
BLAKE2b-256 checksum How to use checksums |
aea945f6decbc6f6cd7927f98d4db2b408743865bb7493dc508f5a8baf72d15e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / genius74o_polydb-0.1.0-py3-none-any.whl
| Download URL | genius74o_polydb-0.1.0-py3-none-any.whl |
|---|---|
| Size | 30.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e3b5fbd72a2ca8f9943d2b4cf966ab1765346bdf066bfe367aa65b9fd51118ce
|
|
BLAKE2b-256 checksum How to use checksums |
5b79362d0ed2e7716505d3dc39c79ffdb9fc05063baf1c6b86d37350ba3e8bbc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Security for genius74o-polydb 0.1.0
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.