Disk-backed HNSW vector database with SQLite metadata
Project description
🐹 NoPokeDB
A tiny, disk-backed vector database built on hnswlib (for approximate nearest neighbor search) and SQLite (for metadata).
Simple, lightweight, and crash-safe — good for prototypes, side projects, or when you don’t want a heavyweight vector DB service.
✨ Features
- Durable: HNSW index + SQLite metadata, persisted on disk
- Crash safety: write-ahead oplog with replay
- Fast: batch inserts, bulk metadata fetch, auto-resize index
- Flexible metrics: cosine / L2 / inner product
- CRUD:
add,add_many,get,delete,upsert - Consistent scoring: higher = better for all metrics (with raw
distanceincluded)
📦 Installation
pip install nopokedb
🚀 Quickstart
import numpy as np
from nopokedb import NoPokeDB
# Create (or load existing) DB with 128-d vectors
db = NoPokeDB(dim=128, max_elements=10_000, path="./vdb_data", space="cosine")
# Insert one vector
vec = np.random.rand(128).astype(np.float32)
vid = db.add(vec, metadata={"name": "foo"})
# Insert many at once (faster)
V = np.random.rand(5, 128).astype(np.float32)
metas = [{"i": i} for i in range(len(V))]
ids = db.add_many(V, metas)
# Query nearest neighbors
q = np.random.rand(128).astype(np.float32)
hits = db.query(q, k=3)
for h in hits:
print(h["id"], h["score"], h["metadata"])
# Get / update / delete
print(db.get(vid))
db.upsert(vid, metadata={"name": "bar"})
db.delete(ids[0])
# Persist & close
db.save()
db.close()
Example query result:
{'id': 0, 'metadata': {'name': 'foo'}, 'score': 0.991, 'distance': 0.009}
🛠 Development
Bump version
The Makefile automates version bumps in pyproject.toml and src/nopokedb/__init__.py:
make bump V=0.2.0
That will:
- update both files
- commit with message
Bump to v0.2.0 - tag
v0.2.0 - push tag + main branch
Publish to PyPI
-
Set your API key once:
export PYPI_API_KEY=your-pypi-token
-
Build + upload:
make publish
📜 License
MIT
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
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 nopokedb-0.5.1.tar.gz.
File metadata
- Download URL: nopokedb-0.5.1.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
389e0c9f926391b3cffe93093d2f666d70673b592c4809a4698c7a4957c960ca
|
|
| MD5 |
e69c3b0b2feef82dab596d1c58388871
|
|
| BLAKE2b-256 |
078e365be59e9b5ed546792ee6f407b56d95683bbafc52c1b229c37a5767af29
|
File details
Details for the file nopokedb-0.5.1-py3-none-any.whl.
File metadata
- Download URL: nopokedb-0.5.1-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
649cbb444a5d76d857636c7d5e67e4dd42580e0fed2641d59af187d98d4cef3b
|
|
| MD5 |
16df9fbf875e173ba63356cec3deebb2
|
|
| BLAKE2b-256 |
c925d404f8aae27f95a2f2561e5d8b203d0bcec9361a7773f750bcee3c7285d7
|