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; add LIMIT n for the n nearest matches
  • 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

# SEMANTIC_MATCH is a top-k search. Without a LIMIT it returns the 10
# nearest matches; add LIMIT to control how many come back:
rows = conn.execute(
    "SELECT id, body FROM docs WHERE SEMANTIC_MATCH(body, 'artificial intelligence', 0.3) LIMIT 50"
)

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":"0.4.0","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.6.0.tar.gz (705.7 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.6.0-cp312-cp312-manylinux_2_28_x86_64.whl (29.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

galaxdb_client-0.6.0-cp312-cp312-manylinux_2_28_aarch64.whl (27.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

galaxdb_client-0.6.0-cp311-cp311-win_amd64.whl (25.5 MB view details)

Uploaded CPython 3.11Windows x86-64

galaxdb_client-0.6.0-cp311-cp311-macosx_11_0_arm64.whl (24.4 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

galaxdb_client-0.6.0-cp311-cp311-macosx_10_12_x86_64.whl (26.1 MB view details)

Uploaded CPython 3.11macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: galaxdb_client-0.6.0.tar.gz
  • Upload date:
  • Size: 705.7 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.6.0.tar.gz
Algorithm Hash digest
SHA256 d6c6280421a2f44d8ad8a14fa1c0ec63bb442debb634b47daa689058e710caba
MD5 8b5f8d566d85fc8f9dd36991987d3dcf
BLAKE2b-256 42322f5f84863ce6ce1abfd10991b2184893f97f01c146f80aa23f6613236c6c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for galaxdb_client-0.6.0-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1473da02d3ac6429f45e05ace9367cbfa86bbbaecce5ccbc1efe05e1c0aeddea
MD5 47cbe3080f968a7757a61d295d451fec
BLAKE2b-256 22119ca54f4bcbc7a73abbf2aae4d099f862af2e9576d43be4baaf50598cb1dd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for galaxdb_client-0.6.0-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 e9301002d37dbc32e8fa68e3ae9246a39b3cd0d47b4035d775f7c1ff29868d4a
MD5 79c5b24667bf4520682c9969f47dec9d
BLAKE2b-256 66126707f8f5e07dc04ef111196975235175bea58480998186650d7ec23ed8fb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for galaxdb_client-0.6.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 8430648f8051f1d6ebba22b35f10cc7c43e1b20f7b3eba258356a4cf1ee90f68
MD5 c65b3a1d5d18e239e1ed858647883d40
BLAKE2b-256 ae984aad363c96e747f2131cb05acd808c9bdf09a22687fa522c0f61d6d15b0f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for galaxdb_client-0.6.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f4005beb482508ccd5e46fa85727ab8beb1c0a8d6e31fae2b12a6cb692e3acc9
MD5 c4a8782691be6c08c051e052df098c0d
BLAKE2b-256 664516f6dae2a4a7d21ee72c89dee649b5d14f4a6499512aa8686669f2f3d0d2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for galaxdb_client-0.6.0-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 f375484f1e2e984aa079704c9a81fe95d828c81a279f81beff6b70b11bced2f4
MD5 0fb38f73ed729d0aabd6e5415424d05d
BLAKE2b-256 e1230605ca3805e6ec54d3d609a95f860cb9eed6c8ae3e4baec191c0dd396501

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