Skip to main content

A surrogate single-node MongoDB server in Python for testing pymongo applications without running a real mongod.

Project description

SecantusDB

Status: alpha Tests: 584 passing License: GPL-2.0-only Python: 3.12+ Documentation Status

[!WARNING] Alpha software — not for production use.

SecantusDB is in early development. The API surface and on-disk format can change between point releases. It exists today as a developer tool for exercising application code against a MongoDB-shaped surrogate; it is not a database for storing data you can't recreate.

A surrogate single-node MongoDB server in Python. SecantusDB speaks the subset of the MongoDB wire protocol that pymongo emits, so test suites can talk to it instead of standing up a real mongod. No binary to install, no port conflicts, parallel-test friendly. Single-node only — replica sets and sharding are out of scope by design.

from pymongo import MongoClient
from secantus import SecantusDBServer

with SecantusDBServer(port=0) as server:
    client = MongoClient(server.uri)
    db = client["mydb"]
    db["users"].insert_one({"_id": 1, "name": "Joe"})
    assert db["users"].find_one({"_id": 1})["name"] == "Joe"

What's in scope

The subset of MongoDB that pymongo actually drives — connection handshake, CRUD, cursors, aggregation, findAndModify — backed by a real query planner with index acceleration (single-field, compound, mixed-direction, partial, TTL, sort), proper explain output (IXSCAN vs COLLSCAN), and a hash-join $lookup.

What's out of scope: replica sets, sharding, change streams, authentication, TLS, text/geo/wildcard indexes, $where, real transaction rollback. If your test depends on those, run a real mongod.

Installation

pip install SecantusDB

Pre-built wheels are published for CPython 3.12 and 3.13 on:

  • macOS arm64 (Apple Silicon)
  • Linux x86_64 and aarch64 (manylinux2014 / glibc, and musllinux_1_2 / Alpine)
  • Windows AMD64

macOS Intel (x86_64) is not in the wheel matrix; use a from-source install if you need it.

WiredTiger is vendored inside the wheel — no separate package, no compile step, no system build tools required.

Building from source (unsupported platforms only)

If your platform isn't in the matrix above, pip install SecantusDB falls back to the sdist and compiles WiredTiger from source. That needs three native build tools on PATH:

  • cmake (>= 3.21)
  • ninja
  • swig (>= 4.0)
Platform Install prerequisites
macOS (Homebrew) brew install cmake ninja swig
Debian/Ubuntu sudo apt-get install -y cmake ninja-build swig
Fedora/RHEL sudo dnf install -y cmake ninja-build swig
Alpine apk add --no-cache cmake ninja swig build-base

See Installation for dev-install instructions.

Examples

A walk through the operations a typical test exercises — connect, insert, index, query, drop. Full version with explanations: examples in the docs.

from pymongo import MongoClient
from secantus import SecantusDBServer

with SecantusDBServer(port=0) as server:
    client = MongoClient(server.uri)
    cellar = client["wine_cellar"]
    bottles = cellar["bottles"]

    # --- Insert ---
    bottles.insert_one(
        {"_id": 1, "name": "Pommard 2018", "region": "Burgundy", "year": 2018}
    )
    bottles.insert_many(
        [
            {"_id": 2, "name": "Brunello 2015", "region": "Tuscany", "year": 2015},
            {"_id": 3, "name": "Barolo 2017", "region": "Piedmont", "year": 2017},
            {"_id": 4, "name": "Pommard 2020", "region": "Burgundy", "year": 2020},
        ]
    )

    # --- Indexes ---
    bottles.create_index([("year", 1)])                     # single-field
    bottles.create_index([("region", 1), ("year", -1)])     # compound

    # --- Query ---
    drinkable_now = list(
        bottles.find({"year": {"$lte": 2018}}).sort("year")
    )
    assert [b["name"] for b in drinkable_now] == [
        "Brunello 2015",
        "Barolo 2017",
        "Pommard 2018",
    ]

    by_region = list(
        bottles.aggregate(
            [
                {"$group": {"_id": "$region", "count": {"$sum": 1}}},
                {"$sort": {"_id": 1}},
            ]
        )
    )

    # --- Drop ---
    bottles.drop()                              # one collection
    client.drop_database("wine_cellar")         # whole database

Documentation

Full docs are in docs/; build them with uv run python -m invoke docs and open docs/_build/html/index.html. Highlights:

  • Quickstart — embedding in tests, running standalone.
  • Architecture — the layered design.
  • Indexes — what find() and aggregate accelerate, explain semantics, hints, partial indexes, TTL.
  • Aggregation — supported pipeline stages and expression operators.
  • Compatibility — the divergences you should know about before you trust SecantusDB for a given test.

Development

git clone https://github.com/jdrumgoole/SecantusDB.git
cd SecantusDB
uv sync --extra dev
uv run python -m pytest    # 584 tests, runs in parallel under pytest-xdist

Common workflows:

uv run python -m invoke fmt    # ruff format
uv run python -m invoke lint   # ruff check
uv run python -m invoke test   # pytest, parallel
uv run python -m invoke docs   # build Sphinx docs (warnings as errors)

License

GPL-2.0-only. See LICENSE. SecantusDB intends to bundle the WiredTiger storage engine (itself GPL-2/GPL-3), so the combined work is GPL.

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

secantusdb-0.2.0a1.tar.gz (5.4 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

secantusdb-0.2.0a1-cp313-cp313-win_amd64.whl (991.1 kB view details)

Uploaded CPython 3.13Windows x86-64

secantusdb-0.2.0a1-cp313-cp313-musllinux_1_2_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

secantusdb-0.2.0a1-cp313-cp313-musllinux_1_2_aarch64.whl (1.2 MB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ ARM64

secantusdb-0.2.0a1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

secantusdb-0.2.0a1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.2 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

secantusdb-0.2.0a1-cp313-cp313-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

secantusdb-0.2.0a1-cp312-cp312-win_amd64.whl (991.2 kB view details)

Uploaded CPython 3.12Windows x86-64

secantusdb-0.2.0a1-cp312-cp312-musllinux_1_2_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

secantusdb-0.2.0a1-cp312-cp312-musllinux_1_2_aarch64.whl (1.2 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ ARM64

secantusdb-0.2.0a1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

secantusdb-0.2.0a1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

secantusdb-0.2.0a1-cp312-cp312-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

File details

Details for the file secantusdb-0.2.0a1.tar.gz.

File metadata

  • Download URL: secantusdb-0.2.0a1.tar.gz
  • Upload date:
  • Size: 5.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for secantusdb-0.2.0a1.tar.gz
Algorithm Hash digest
SHA256 7944fd0f09f4fb9534da2a3d233da2bdb12ed7565b5f01d00ba1ed097021b02c
MD5 71e720649f4d016b26089af065b6195b
BLAKE2b-256 07658d7918fb6588126262fb95e0b83d157fd2a6b18cb61880b38746194ac8dc

See more details on using hashes here.

Provenance

The following attestation bundles were made for secantusdb-0.2.0a1.tar.gz:

Publisher: publish.yml on jdrumgoole/SecantusDB

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file secantusdb-0.2.0a1-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for secantusdb-0.2.0a1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 7f199549f36747d33f13cb99997b64e1d1dce146c1be98fb6eaa764c3bb08633
MD5 ec55af79cc9052034dd6033aaabfe9f7
BLAKE2b-256 566e5d4ce1be120a2e73201619aa42efba8673b12f4f56be1036a25a05f94a64

See more details on using hashes here.

Provenance

The following attestation bundles were made for secantusdb-0.2.0a1-cp313-cp313-win_amd64.whl:

Publisher: publish.yml on jdrumgoole/SecantusDB

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file secantusdb-0.2.0a1-cp313-cp313-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for secantusdb-0.2.0a1-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 b50ee755c811e88518a021c91b527b661a02c0f36f45c94eeb61aec2be86fc33
MD5 6a02fe462c813c9db7f0675ace5a05c1
BLAKE2b-256 b088b66e33d4e7885ec76dfe31ec571cda692b6fc940cb5a7fb1d287d299264b

See more details on using hashes here.

Provenance

The following attestation bundles were made for secantusdb-0.2.0a1-cp313-cp313-musllinux_1_2_x86_64.whl:

Publisher: publish.yml on jdrumgoole/SecantusDB

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file secantusdb-0.2.0a1-cp313-cp313-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for secantusdb-0.2.0a1-cp313-cp313-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 7106cc454cff2d18c07c8d5bf1aad4b941bbe323644c8152c160142ee204d800
MD5 b2c0e8067e58bf9097f61cd7cca6c37a
BLAKE2b-256 c26aba9be4b1073528d96a5539dacc3521365d3f06884b57faef266410566998

See more details on using hashes here.

Provenance

The following attestation bundles were made for secantusdb-0.2.0a1-cp313-cp313-musllinux_1_2_aarch64.whl:

Publisher: publish.yml on jdrumgoole/SecantusDB

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file secantusdb-0.2.0a1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for secantusdb-0.2.0a1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d3616c9f5355fb6fbe50489e80a2a32d6d4be1d9368ae00da530adc31d392844
MD5 884ba76a176208fdc566d19176f081cf
BLAKE2b-256 61aa6bedadfea99a3001d583b5c28d726a6891a60061ebd1f2d4da61eeecbd82

See more details on using hashes here.

Provenance

The following attestation bundles were made for secantusdb-0.2.0a1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yml on jdrumgoole/SecantusDB

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file secantusdb-0.2.0a1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for secantusdb-0.2.0a1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 9cf8c1ba4b0e1a3d5c5b9f49cb3531062a55434c68ff719cf3dad47368404658
MD5 38bd43fd9c70014b84a1311e5c37db02
BLAKE2b-256 f7a7a87a6ce77ce6e0769841f13f76116933da873e775880642071c7821a6f79

See more details on using hashes here.

Provenance

The following attestation bundles were made for secantusdb-0.2.0a1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: publish.yml on jdrumgoole/SecantusDB

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file secantusdb-0.2.0a1-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for secantusdb-0.2.0a1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bd4a4f39cf58f1da50deee66a70cccedf37fa4fd5bedda24ff0e14b1f9f28416
MD5 7c2cf81b461e42ef9322a55682ed9e9e
BLAKE2b-256 471e5252581226d93105d49d1790948da2d3f82af3df408a9de874bf98a66209

See more details on using hashes here.

Provenance

The following attestation bundles were made for secantusdb-0.2.0a1-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: publish.yml on jdrumgoole/SecantusDB

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file secantusdb-0.2.0a1-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for secantusdb-0.2.0a1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 42a05c1c77da12a91a8c6f6a43776a865dc6759bb81b831ed3331f722ee53714
MD5 0f0cfb80d17374e0ce395decdbdf428b
BLAKE2b-256 1171db119ca2c0925f004f73a3dcd24aa79a69ecea1ca4b6df4b707253dba2b3

See more details on using hashes here.

Provenance

The following attestation bundles were made for secantusdb-0.2.0a1-cp312-cp312-win_amd64.whl:

Publisher: publish.yml on jdrumgoole/SecantusDB

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file secantusdb-0.2.0a1-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for secantusdb-0.2.0a1-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 d1b2c8852c6e8100fc849449f4847ca9856f8546754a0f2431def60d89c46d0c
MD5 796ad798839cba8a6003b53ebe8b1d3c
BLAKE2b-256 58930d6fe74adcc2e4d309dde822817585bb51e6a197e5a6846ac057b858c430

See more details on using hashes here.

Provenance

The following attestation bundles were made for secantusdb-0.2.0a1-cp312-cp312-musllinux_1_2_x86_64.whl:

Publisher: publish.yml on jdrumgoole/SecantusDB

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file secantusdb-0.2.0a1-cp312-cp312-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for secantusdb-0.2.0a1-cp312-cp312-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 57f3d34386b2e7c9f788b318d80ddc2cf901c4caa814928514c09a90f8a8ba71
MD5 3f42559c2927068152831eac3eb6301c
BLAKE2b-256 b9207cd10abcab62407c6f29a74c2bc8db2452d0a789d3667b8a20c7831cd64e

See more details on using hashes here.

Provenance

The following attestation bundles were made for secantusdb-0.2.0a1-cp312-cp312-musllinux_1_2_aarch64.whl:

Publisher: publish.yml on jdrumgoole/SecantusDB

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file secantusdb-0.2.0a1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for secantusdb-0.2.0a1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1010e6b0e986a18d373dd8515513766361698fd4c94f5eff59f9e7d2066da4c5
MD5 7305514bb0ea58049a2cae5f797b3ed0
BLAKE2b-256 10051c7fb09597615e9a10cb5bcd3af0a4e5b548b69e4050fe8b2fad8c538b33

See more details on using hashes here.

Provenance

The following attestation bundles were made for secantusdb-0.2.0a1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yml on jdrumgoole/SecantusDB

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file secantusdb-0.2.0a1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for secantusdb-0.2.0a1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f2cbdfdadb4505e6be3124c723f9bf141742ff720869372cc3c38df4585c1d43
MD5 90d8cd988a1644dc6223cce7ab67d382
BLAKE2b-256 c77e41deaa99ae95f8575684cf8989490ca09f02ddf49c1ab395da57dbb61390

See more details on using hashes here.

Provenance

The following attestation bundles were made for secantusdb-0.2.0a1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: publish.yml on jdrumgoole/SecantusDB

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file secantusdb-0.2.0a1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for secantusdb-0.2.0a1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7c36fef36010748b75bd8093a12be260f84a9fae86217802e3ae8cffbec6ba8b
MD5 4578ad313ed31483751970db9544c3b7
BLAKE2b-256 49efa3457b8e8fc29a517e2c40266845d5f9a882cf7ab8d9590c0ec2e546becd

See more details on using hashes here.

Provenance

The following attestation bundles were made for secantusdb-0.2.0a1-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: publish.yml on jdrumgoole/SecantusDB

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page