Provision Docker databases in Python — Postgres, Neo4j, MongoDB, MySQL, MSSQL with a unified one-call API
Project description
py-dockerdb
Pythonic Docker database management for notebooks, tutorials, and fast MVPs.
pip install py-dockerdb
py-dockerdb gives you one Python API to create, connect, and clean up Docker
databases: PostgreSQL, MySQL, MongoDB, MSSQL, Redis, Neo4j, and Ollama. It is built
for people who teach, demo, and prototype with notebooks and need repeatable local
databases in seconds.
Switch from PostgreSQL to MongoDB without changing a line of connection code. Test a pgvector RAG pipeline, then swap to Neo4j for GraphRAG with one config change. Or hand every student a pre-seeded database at the start of class without touching Docker on their machine.
When to use this
- Teaching a SQL workshop: two lines give every learner a working, pre-seeded database, identical across Windows/Mac/Linux.
- Comparing databases for an MVP: run Postgres, MongoDB, Redis, and Neo4j through the same interface and pick based on behaviour, not setup time.
- Local RAG prototype: spin up pgvector, validate retrieval, swap to another backend in one config change without touching orchestration code.
- GraphRAG with Neo4j:
Neo4jDB.connectionreturns aneo4j.Driverthat plugs directly into LlamaIndex'sNeo4jGraphStoreand LangChain'sNeo4jGraph.
Supported Databases
Prerequisites
- Python 3.10+ · Docker running
Installation
pip install py-dockerdb # core
pip install "py-dockerdb[graph]" # + Neo4j / LlamaIndex / LangChain
pip install "py-dockerdb[rag]" # + pgvector / LlamaIndex
Usage
Define a config, call create_db(), run your workload, tear down with delete_db().
PostgreSQL
from docker_db.dbs.postgres_db import PostgresConfig, PostgresDB
db = PostgresDB(PostgresConfig(user="u", password="p", database="d", project_name="demo"))
db.create_db()
conn = db.connection # psycopg2 connection
cur = conn.cursor()
cur.execute("SELECT version();")
print(cur.fetchone())
db.delete_db(running_ok=True)
Neo4j / GraphRAG
from docker_db.dbs.neo4j_db import Neo4jConfig, Neo4jDB
db = Neo4jDB(Neo4jConfig(password="p", project_name="demo"))
db.create_db()
driver = db.connection # neo4j.Driver -> hand to Neo4jGraphStore or Neo4jGraph
with driver.session() as s:
s.run("CREATE (n:Person {name: 'Alice'})")
print(s.run("MATCH (n:Person) RETURN n.name").single()[0])
db.delete_db(running_ok=True)
Ollama
from docker_db.dbs.ollama_db import OllamaConfig, OllamaDB
db = OllamaDB(OllamaConfig(project_name="demo"))
db.create_db()
session = db.connection # requests.Session
db.pull_model("llama3")
resp = session.post(f"{db.base_url}/api/generate", json={"model": "llama3", "prompt": "Hello", "stream": False})
print(resp.json()["response"])
db.delete_db(running_ok=True)
More examples
Full runnable notebooks are in usage/:
PostgreSQL · MySQL · MongoDB · MSSQL · Redis · Neo4j / GraphRAG · pgvector RAG · Lifecycle
Roadmap
- PostgreSQL +
pgvector - Neo4j
- Qdrant
- Chroma
- Weaviate
- Milvus
Development
git clone https://github.com/amadou-6e/docker-db.git
cd docker-db
pip install -e ".[test]"
Testing
python -m pytest -vv -s tests/test_manager.py
python -m pytest -vv -s tests/test_postgres.py
python -m pytest -vv -s tests/test_postgres_pgvector.py
python -m pytest -vv -s tests/test_mysql.py
python -m pytest -vv -s tests/test_mongodb.py
python -m pytest -vv -s tests/test_mssql.py
python -m pytest -vv -s tests/test_redis.py
python -m pytest -vv -s tests/test_cassandra.py
python -m pytest -vv -s tests/test_neo4j.py
python -m pytest -vv -s tests/test_opensearch.py
python -m pytest -vv -s tests/test_qdrant.py
python -m pytest -vv -s tests/test_ollama.py
python -m pytest -vv -s tests/test_notebooks.py
Contributing
PRs welcome. Include tests for behaviour changes and keep notebooks runnable.
License
MIT License. See LICENSE.
Project details
Release history Release notifications | RSS feed
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 py_dockerdb-1.0.0.tar.gz.
File metadata
- Download URL: py_dockerdb-1.0.0.tar.gz
- Upload date:
- Size: 48.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0730fc347bac72be2a22084064982b16360490a9b399547acc185f4c9e71c546
|
|
| MD5 |
ba92541a77766ec4b1f4ab88ddcff18f
|
|
| BLAKE2b-256 |
75e8f2191e42b2fa2942b9fb9abb276854353ba904f1c372849696b7e3dc0885
|
Provenance
The following attestation bundles were made for py_dockerdb-1.0.0.tar.gz:
Publisher:
cicd.yml on amadou-6e/py-docker
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
py_dockerdb-1.0.0.tar.gz -
Subject digest:
0730fc347bac72be2a22084064982b16360490a9b399547acc185f4c9e71c546 - Sigstore transparency entry: 1033173434
- Sigstore integration time:
-
Permalink:
amadou-6e/py-docker@a1479bea559ff289b647c9efd1ff3815d5af95e6 -
Branch / Tag:
refs/tags/1.0.0 - Owner: https://github.com/amadou-6e
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cicd.yml@a1479bea559ff289b647c9efd1ff3815d5af95e6 -
Trigger Event:
release
-
Statement type:
File details
Details for the file py_dockerdb-1.0.0-py3-none-any.whl.
File metadata
- Download URL: py_dockerdb-1.0.0-py3-none-any.whl
- Upload date:
- Size: 43.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
40853481f97d15b468a89648dc52ea7ca41050c4889eb2b35b76eec5561130f7
|
|
| MD5 |
544ad467f2844b65c210f1f138089630
|
|
| BLAKE2b-256 |
d56a0a4daeba4049c15fd76a29ccaecb361417531fa5874733cc8b4e78a614b8
|
Provenance
The following attestation bundles were made for py_dockerdb-1.0.0-py3-none-any.whl:
Publisher:
cicd.yml on amadou-6e/py-docker
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
py_dockerdb-1.0.0-py3-none-any.whl -
Subject digest:
40853481f97d15b468a89648dc52ea7ca41050c4889eb2b35b76eec5561130f7 - Sigstore transparency entry: 1033173477
- Sigstore integration time:
-
Permalink:
amadou-6e/py-docker@a1479bea559ff289b647c9efd1ff3815d5af95e6 -
Branch / Tag:
refs/tags/1.0.0 - Owner: https://github.com/amadou-6e
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cicd.yml@a1479bea559ff289b647c9efd1ff3815d5af95e6 -
Trigger Event:
release
-
Statement type: