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.4.0.tar.gz (655.9 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.4.0-cp312-cp312-manylinux_2_28_x86_64.whl (30.4 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

galaxdb_client-0.4.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.4.0.tar.gz.

File metadata

  • Download URL: galaxdb_client-0.4.0.tar.gz
  • Upload date:
  • Size: 655.9 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.4.0.tar.gz
Algorithm Hash digest
SHA256 73c0b2cb513546c08689aade5480ff470011a18d42bdceca761d951ec18bc737
MD5 ad95057ccf92f09bd85de8063ac47aad
BLAKE2b-256 70ff3b9a53e95edb922c0b59a0cfd45e4f67077308c96419a250ae028be99236

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for galaxdb_client-0.4.0-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3d916514f4475ab75bc81d6bcccaf1946454cef2bb8bbda1471bbcfacc8c339f
MD5 e086320870eb216d45c2fc6c94df9af7
BLAKE2b-256 ce9e39a8bc66e6a270c836542f77800a1d0a563755b11b2c1e62b87135ea90bb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for galaxdb_client-0.4.0-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 94a2a092d31e2e2005563c564d74978fac0b8d7ece0f783154b4f07a8e3fa256
MD5 cb111fbbe22aeba942e723e93ffec34c
BLAKE2b-256 f6035aaf4ff047bd62b25832acb72856f1f3b62d428e34c64c636f4f1dcb7199

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for galaxdb_client-0.4.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 7090a8a7e6efa7bac517a0293dbb3649abcf6ed92c61915f70d192c93cc15743
MD5 90b0c3d32b7eae9dc132b0fbbcc86b66
BLAKE2b-256 a3ffdf12b1abc296b9450a193c80e72206584ec3c3db11b2b3274148d43b203c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for galaxdb_client-0.4.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 179631def4dad6022b5cba3c7029a9d6a9a00ac0a175a771ed2fc6d1b76f26da
MD5 7a4320ed863d23e008f63b1b52595f0e
BLAKE2b-256 6cc2190cafe9e3d89ae11a3e6d8910836948b2a7bf8b520ef11ca5cd23f24123

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for galaxdb_client-0.4.0-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 04f9dc77c4a22e404ce711c7a008ab57500f071c6701a484abb97b86673ba6fc
MD5 1fb924c413b7c181394cf937db0e61d3
BLAKE2b-256 90122bbbb3966b2c51a50ffc4deca69e28d0dd285750f1850dd3fc487a74a547

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