Skip to main content

NeoSQLite Experimental Project 27017 - MongoDB Wire Protocol Server

Project description

NX-27017

"To Boldy Go Where No SQLite Has Gone Before!"

A MongoDB Wire Protocol Server backed by SQLite. In plain English: we turned a simple SQLite file into a MongoDB server. Yes, this is exactly as crazy as it sounds.

Wait, What?

You know how SQLite is that tiny database that just... works? And you wish you could point your PyMongo app at it without rewriting everything?

That's NX-27017. It speaks MongoDB's wire protocol, stores everything in SQLite, and pretends nothing is wrong.

Note: The NX stands for "NeoSQLite Experimental" - our little NX-class starship of database adapters. 🚀

Requirements

  • Python 3.10+
  • pymongo - Yes, the real pymongo. It includes bson so no separate bson package needed. cough not to be confused with the other bson package on PyPi cough
pip install pymongo neosqlite

Quick Start

# Run with in-memory storage (gone when you stop)
nx-27017 --db memory

# Run with a file (persistent)
nx-27017 --db ./myapp.db

# Run with specific journal mode (WAL is default)
nx-27017 --db ./myapp.db -j DELETE

# Daemon mode
nx-27017 -d --db ./myapp.db

Command Line Options

Option Description
--db DB_PATH SQLite database (default: nx-27017.db, use memory for RAM)
--host HOST Bind address (default: 127.0.0.1)
-p PORT Port (default: 27017)
-j MODE SQLite journal mode (default: WAL). Modes: WAL, DELETE, TRUNCATE, PERSIST, MEMORY, OFF
-d Run as daemon
--stop Stop daemon
--status Check if running
--fts5-tokenizer NAME=PATH Load FTS5 tokenizer (can be repeated for multiple tokenizers)
-v Verbose logging

Journal Mode

NX-27017 supports configurable SQLite journal modes via -j or --journal-mode:

# WAL mode (default) - best concurrency
nx-27017 --db ./myapp.db -j WAL

# DELETE mode - traditional rollback journal
nx-27017 --db ./myapp.db -j DELETE

# MEMORY mode - journal in RAM (fast but no crash recovery)
nx-27017 --db ./myapp.db -j MEMORY

For more details on journal modes, see the NeoSQLite documentation.

FTS5 Tokenizer

For databases with FTS5 custom tokenizers (e.g., ICU tokenizer):

nx-27017 --db myapp.db --fts5-tokenizer icu=/path/to/libfts5_icu.so
# Multiple tokenizers:
nx-27017 --db myapp.db --fts5-tokenizer icu=/path.so --fts5-tokenizer other=/other.so

Try It Out

# Terminal 1: Start the server
nx-27017 --db memory -v

# Terminal 2: Connect with mongosh
mongosh mongodb://127.0.0.1:27017

# In mongosh:
db.users.insertOne({ name: "Picard", rank: "Captain" })
db.users.insertOne({ name: "Riker", rank: "Commander" })
db.users.find()

What Works

Category Commands
Handshake ping, ismaster, hello, buildInfo
CRUD insert, find, update, delete, replace_one
Aggregation aggregate, count, distinct with all common stages
Collections create, drop, renameCollection, listCollections, listCollectionNames
Indexes createIndexes, listIndexes, dropIndexes, listSearchIndexes
GridFS find, delete, upload, openDownloadStream on .files collections
Sessions startSession, endSessions
Query Features hint, min, max, sort, skip, limit, projection

GridFS Support

NX-27017 supports GridFS operations via the MongoDB wire protocol:

from pymongo import MongoClient
from gridfs import GridFS

client = MongoClient('mongodb://localhost:27017/')
db = client.my_database
fs = GridFS(db)

# Upload
file_id = fs.put(b"Hello GridFS!", filename="hello.txt")

# Download
content = fs.get(file_id).read()

# List and delete
for f in fs.find():
    print(f.filename, f.length)
fs.delete(file_id)

What Doesn't (Yet)

  • Replication & sharding (coming never™)
  • Change streams via replica set (Note: SQLite-trigger-based watch() is supported!)
  • Transactions (requires replica set)
  • find_raw_batches with batch_size (requires cursor state management)

API Compatibility

NX-27017 passes the 376 MongoDB API compatibility tests (359 passed, 17 skipped) when compared against PyMongo's expected behavior. This includes:

  • All CRUD operations
  • Query operators ($eq, $gt, $gte, $lt, $lte, $ne, $in, $nin, $exists, $type, $all, $size, $regex, $nor, etc.)
  • Update operators ($set, $inc, $push, $pull, $addToSet, $pop, etc.)
  • Aggregation stages ($match, $group, $sort, $limit, $skip, $project, $unwind, $lookup, $facet, etc.)
  • Index operations (including text search indexes)
  • Cursor methods (hint, min, max, sort)

Architecture

PyMongo Client ←→ NX-27017 (Wire Protocol) ←→ SQLite (via NeoSQLite)
                      ↓
            "A database inside a database?"
            "It's more like... a database wearing a database costume."

Why Though?

Honestly? Because we could. And because sometimes you want:

  • One file = one database
  • Zero setup
  • A MongoDB-shaped interface to SQLite
  • The satisfaction of doing something ridiculous that somehow works

License

Part of the NeoSQLite project. Use freely, modify liberally, blame no one.


NX-27017: Not The Final Frontier of SQLite Possibility.

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

nx_27017-0.3.0.tar.gz (33.0 kB view details)

Uploaded Source

Built Distribution

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

nx_27017-0.3.0-py3-none-any.whl (32.3 kB view details)

Uploaded Python 3

File details

Details for the file nx_27017-0.3.0.tar.gz.

File metadata

  • Download URL: nx_27017-0.3.0.tar.gz
  • Upload date:
  • Size: 33.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.14.3 Linux/6.19.8-200.fc43.x86_64

File hashes

Hashes for nx_27017-0.3.0.tar.gz
Algorithm Hash digest
SHA256 7de609d892f1454a40c28834a1c2c52551f3e95d3054ac47c148cfb2f5922637
MD5 7c36ec7f4994b3b0d3d3a1995ad4abf9
BLAKE2b-256 4140c15ec63fdaf5246940b1c82cd55a88199069d28c28e06d92cc9502c2770c

See more details on using hashes here.

File details

Details for the file nx_27017-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: nx_27017-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 32.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.14.3 Linux/6.19.8-200.fc43.x86_64

File hashes

Hashes for nx_27017-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1d30966ca84f5bd4af52c6b1a168a0dda346bb522befa1ef479c4a4b9b7c8997
MD5 af557e37dba86e7e9462453d7505227a
BLAKE2b-256 f4d66c3b86cea2c76d6fb66473071b84fc3c3b537d3094b152f3b823de883698

See more details on using hashes here.

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