Skip to main content

py-dockerdb

Pythonic Docker database management for notebooks, tutorials, and fast MVPs.

Build PyPI License Docs

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.connection returns a neo4j.Driver that plugs directly into LlamaIndex's Neo4jGraphStore and LangChain's Neo4jGraph.

Supported Databases

PostgreSQL MySQL MongoDB SQL Server Redis Neo4j Ollama

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.

Metadata

Release files for py-dockerdb 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py-dockerdb 1.0.0
File Size Uploaded
py_dockerdb-1.0.0.tar.gz 48.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for py-dockerdb 1.0.0
File Interpreter ABI Platform
py_dockerdb-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 92.3 kB

Release files / py_dockerdb-1.0.0.tar.gz

Download URL py_dockerdb-1.0.0.tar.gz
Size 48.9 kB
Tags Source
SHA-256 checksum
How to use checksums
0730fc347bac72be2a22084064982b16360490a9b399547acc185f4c9e71c546
BLAKE2b-256 checksum
How to use checksums
75e8f2191e42b2fa2942b9fb9abb276854353ba904f1c372849696b7e3dc0885
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Mar 4, 2026.

Transparency log

Release files / py_dockerdb-1.0.0-py3-none-any.whl

Download URL py_dockerdb-1.0.0-py3-none-any.whl
Size 43.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
40853481f97d15b468a89648dc52ea7ca41050c4889eb2b35b76eec5561130f7
BLAKE2b-256 checksum
How to use checksums
d56a0a4daeba4049c15fd76a29ccaecb361417531fa5874733cc8b4e78a614b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Mar 4, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page