Skip to main content

GalaxDB Python client -- SQL, vector search, and local embeddings in one database

Project description

galaxdb-client

The Python client for GalaxDB -- an AI-native database that combines SQL, vector search, and local embeddings in a single binary.

No external API keys. No separate vector database. No data pipeline. One connection string.

Installation

pip install galaxdb-client

Requires Python 3.9+. Pre-built wheels for Linux x86_64, macOS Intel, macOS Apple Silicon, and Windows x86_64.

What GalaxDB gives you

  • Full SQL -- CREATE, INSERT, UPDATE, DELETE, SELECT with WHERE filters
  • Local embeddings -- text to vector conversion runs inside the process, no API key needed
  • Semantic search -- SEMANTIC_MATCH(col, 'query', threshold) in any WHERE clause
  • HNSW vector index -- recall@10 = 0.990 on SIFT-1M at ef=200
  • Time-travel queries -- SELECT ... AT VERSION 'tag' to query historical snapshots
  • Training export -- CREATE VERSION TAG ... FOR TRAINING exports a Lance dataset, zero-copy PyTorch-ready
  • Near-dedup -- WHERE NOT DUPLICATE removes near-duplicate rows using MinHash LSH
  • Crash safety -- WAL + checksum, 7 chaos scenarios pass in under 11 seconds
  • Encryption at rest -- AES-256-GCM on every block and WAL record

Quick start -- embedded mode (no server)

import galaxdb

# Open or create a database at a local path
db = galaxdb.Database("/tmp/mydb")

# Create a table
db.execute("CREATE TABLE products (id INT PRIMARY KEY, name TEXT, price INT)")

# Insert rows
db.execute("INSERT INTO products (id, name, price) VALUES (1, 'Laptop', 1200)")
db.execute("INSERT INTO products (id, name, price) VALUES (2, 'Headphones', 150)")
db.execute("INSERT INTO products (id, name, price) VALUES (3, 'Keyboard', 80)")

# Query with filter
rows = db.execute("SELECT * FROM products WHERE price > 100")
for row in rows:
    print(row)
# {'id': '1', 'name': 'Laptop', 'price': '1200'}
# {'id': '2', 'name': 'Headphones', 'price': '150'}

# Update
db.execute("UPDATE products SET price = 1100 WHERE id = 1")

# Delete
db.execute("DELETE FROM products WHERE id = 3")

# Table info
print(db.table_exists("products"))  # True
print(db.table_count)               # 1

Semantic search with local embeddings

Start the server with the embedding sidecar to enable SEMANTIC_MATCH:

galaxdb-server \
  --data-dir ./data \
  --port 5433 \
  --sidecar /usr/local/bin/galaxdb-sidecar \
  --model sentence-transformers/all-MiniLM-L6-v2

Then connect from Python:

import galaxdb

conn = galaxdb.connect("host=localhost port=5433 dbname=galaxdb sslmode=disable")

# Create a table with an embedding column
conn.execute("""
    CREATE TABLE docs (
        id   INT PRIMARY KEY,
        body TEXT EMBEDDING MODEL 'sentence-transformers/all-MiniLM-L6-v2' DIM 384
    )
""")

# Insert rows -- embeddings are computed automatically by the local sidecar
conn.execute("INSERT INTO docs (id, body) VALUES (1, 'machine learning and neural networks')")
conn.execute("INSERT INTO docs (id, body) VALUES (2, 'rust programming language systems')")
conn.execute("INSERT INTO docs (id, body) VALUES (3, 'cooking recipes italian pasta')")
conn.execute("INSERT INTO docs (id, body) VALUES (4, 'deep learning transformers attention')")

# Semantic search -- no external API, no separate vector DB
rows = conn.execute(
    "SELECT id, body FROM docs WHERE SEMANTIC_MATCH(body, 'artificial intelligence', 0.4)"
)
for row in rows:
    print(row)
# Returns rows 1 and 4 -- the AI/ML related documents

conn.close()

Time-travel queries

# Create a named snapshot
conn.execute("CREATE VERSION TAG 'v1' FOR TRAINING WITH TRAINING PRECISION 'float32'")

# Insert more data after the snapshot
conn.execute("INSERT INTO docs (id, body) VALUES (5, 'new document added later')")

# Query the snapshot -- only sees data from before the tag
rows = conn.execute("SELECT * FROM docs AT VERSION 'v1'")
# Returns rows 1-4, not row 5

Training export

import galaxdb
import lance
import torch

db = galaxdb.Database("./data")

# Create a training snapshot
db.execute("CREATE VERSION TAG 'train-v1' FOR TRAINING WITH TRAINING PRECISION 'float32'")

# Export as a Lance dataset
path = db.training_dataset("train-v1")

# Load into PyTorch -- zero-copy, memory-mapped
dataset = lance.dataset(path).to_pytorch()
loader = torch.utils.data.DataLoader(dataset, batch_size=32)

Bulk insert

conn.execute("""
    BULK INSERT INTO products (id, name, price) VALUES
      (10, 'Monitor', 400),
      (11, 'Mouse', 30),
      (12, 'Webcam', 90)
""")

Near-duplicate deduplication

# Select only unique documents (one per near-duplicate cluster)
rows = conn.execute("SELECT * FROM docs WHERE NOT DUPLICATE")

Backup and restore

conn.execute("BACKUP TO '/path/to/backup'")
conn.execute("RESTORE FROM '/path/to/backup'")

Server mode -- connect to a running GalaxDB server

import galaxdb

# Connect using a PostgreSQL-style connection string
conn = galaxdb.connect("host=localhost port=5433 dbname=galaxdb sslmode=disable")

conn.execute("CREATE TABLE users (id INT PRIMARY KEY, name TEXT, age INT)")
conn.execute("INSERT INTO users (id, name, age) VALUES (1, 'Alice', 30)")

rows = conn.execute("SELECT * FROM users WHERE age > 25")
for row in rows:
    print(row)

conn.close()

Any PostgreSQL client works -- psycopg2, SQLAlchemy, tokio-postgres, pg (Node.js), JDBC.

Docker

docker run -d -p 5433:5433 -p 9090:9090 \
  -v /data:/data \
  -v ~/.cache/huggingface:/root/.cache/huggingface \
  harbi256/galaxdb:latest \
  --data-dir /data \
  --sidecar /usr/local/bin/galaxdb-sidecar \
  --model sentence-transformers/all-MiniLM-L6-v2

Observability

# Health check
curl http://localhost:9090/health
# {"status":"ok","version":"1.0.0-beta.1","subsystems":{"sidecar_healthy":true}}

# Prometheus metrics
curl http://localhost:9090/metrics

Links

License

Apache 2.0

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

galaxdb_client-0.3.0.tar.gz (654.2 kB view details)

Uploaded Source

Built Distributions

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

galaxdb_client-0.3.0-cp312-cp312-manylinux_2_28_x86_64.whl (30.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

galaxdb_client-0.3.0-cp312-cp312-manylinux_2_28_aarch64.whl (27.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

galaxdb_client-0.3.0-cp311-cp311-win_amd64.whl (25.8 MB view details)

Uploaded CPython 3.11Windows x86-64

galaxdb_client-0.3.0-cp311-cp311-macosx_11_0_arm64.whl (25.1 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

galaxdb_client-0.3.0-cp311-cp311-macosx_10_12_x86_64.whl (27.0 MB view details)

Uploaded CPython 3.11macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: galaxdb_client-0.3.0.tar.gz
  • Upload date:
  • Size: 654.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for galaxdb_client-0.3.0.tar.gz
Algorithm Hash digest
SHA256 459097218973a2c57e31a7e42d9739ebab454bb9a351aa3bc0b854acdb1fab1a
MD5 760de8ffce097d5658d4f5d34ed438d5
BLAKE2b-256 ee893f33c479392493c2bdb6d994d28baf8d43900b2ed28d08499120cc67b59c

See more details on using hashes here.

File details

Details for the file galaxdb_client-0.3.0-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for galaxdb_client-0.3.0-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 daae6f27b3c067fe7725a04f2950b775fa22174176618e178e316cd2bebd3e2d
MD5 b9c5b16183a90b066b2d1b78b9fd6781
BLAKE2b-256 0349bb53e4d7b682b8a255c4ab3575afc3920d81ea699b48da0823af2cc98bb3

See more details on using hashes here.

File details

Details for the file galaxdb_client-0.3.0-cp312-cp312-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for galaxdb_client-0.3.0-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 9ab31c37097852269170f0e717beaa54b0e9d703bbb71b11b7654bae862eec5e
MD5 49fdcd92b114b09b542497ee7a74ea4e
BLAKE2b-256 4f5560bdeae7b72f92a9aa9b7b3ddf5d320b53c369562b672151363c52031422

See more details on using hashes here.

File details

Details for the file galaxdb_client-0.3.0-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for galaxdb_client-0.3.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 dbc7bf9703c70f0752b2c1f757b8194202cf60e6c697b2107f415d74240df544
MD5 61011bf640485094fbe4707d8d8a85ae
BLAKE2b-256 534490cc944454fc7970565c5a4c47bf4b4993fc78205dc0d863500167884454

See more details on using hashes here.

File details

Details for the file galaxdb_client-0.3.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for galaxdb_client-0.3.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e8c19c5b394c26e1d2112a145362f03727ae8ae2266866005668f2eb7cf06931
MD5 10c4c8b26233b186eaf1df1967662d82
BLAKE2b-256 064fcc47e9ef55967a7774dcee2590b6af884094d3179f7e9263288e89f90d93

See more details on using hashes here.

File details

Details for the file galaxdb_client-0.3.0-cp311-cp311-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for galaxdb_client-0.3.0-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 9946fdb58345d81992e95c27648f58618754c1ae1300cc891e6149d376e0bf4c
MD5 0aaf77d60f0cb1dff2801c99cd95f965
BLAKE2b-256 2ae57190b02b48debfcfd224e37cf4f70543dad5583a4502fd48f20d48777bf4

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