SQLAlchemy dialect for the SingleStoreDB database
Maintained. Last release 3 weeks ago, commits in 4 of the last 26 weeks. Weaker on commit activity and release cadence.
$
pip install sqlalchemy-singlestoredbREADME as published on PyPI with version 1.2.2.
SingleStoreDB SQLAlchemy Dialect
This project contains a SQLAlchemy dialect which allows you to use the SQLAlchemy APIs with the SingleStoreDB database.
Features
- SingleStore-specific data types: VECTOR for AI/ML embeddings, JSON for semi-structured data
- Computed columns: PersistedColumn for server-side computed values
- Data distribution: ShardKey for optimal data partitioning across nodes
- Query optimization: SortKey for improved query performance
- Vector similarity search: VectorKey for AI/ML similarity operations
- Full-text search: FullTextIndex for text search capabilities
- JSON array indexing: MultiValueIndex for efficient JSON array queries
- Table types: ColumnStore (analytical) and RowStore (transactional) with reference table support
- Wide table optimization: ColumnGroup for tables with many columns
Install
This package can be installed from PyPI using pip:
pip install sqlalchemy-singlestoredb
Quick Start
Connecting to SingleStoreDB
from sqlalchemy import create_engine, text
# Basic connection
engine = create_engine('singlestoredb://user:password@host:3306/database')
# Test the connection
with engine.connect() as conn:
result = conn.execute(text('SELECT 1'))
print(result.fetchone())
Creating Tables (Core API)
from sqlalchemy import Column, DateTime, Integer, MetaData, String, Table
from sqlalchemy_singlestoredb import ShardKey, SortKey, VECTOR, JSON
metadata = MetaData()
users = Table(
'users', metadata,
Column('id', Integer, primary_key=True),
Column('name', String(100)),
Column('email', String(255)),
Column('created_at', DateTime),
singlestoredb_shard_key=ShardKey('id'),
singlestoredb_sort_key=SortKey('created_at'),
)
metadata.create_all(engine)