sqlalchemy_singlestoredb.ColumnStore¶
- class sqlalchemy_singlestoredb.ColumnStore(reference: bool = False, temporary: bool = False)¶
SingleStore columnstore table type specification.
Columnstore tables are disk-based tables optimized for analytical workloads (OLAP) with fast scans and aggregations over large datasets. This is the default table type in SingleStore.
- Parameters:
Note
global_temporary is not supported for columnstore tables.
Examples
Basic columnstore table (default):
>>> ColumnStore()
Temporary columnstore table:
>>> ColumnStore(temporary=True)
Reference columnstore table:
>>> ColumnStore(reference=True)
Table Usage:
from sqlalchemy import Column, DateTime, Integer, MetaData, Numeric, Table from sqlalchemy_singlestoredb import ColumnStore metadata = MetaData() analytics = Table( 'analytics', metadata, Column('id', Integer, primary_key=True), Column('user_id', Integer), Column('event_time', DateTime), Column('amount', Numeric(10, 2)), singlestoredb_table_type=ColumnStore(), ) # Temporary columnstore table temp_analytics = Table( 'temp_analytics', metadata, Column('id', Integer), Column('data', Integer), singlestoredb_table_type=ColumnStore(temporary=True), ) # Reference columnstore table country_codes = Table( 'country_codes', metadata, Column('code', String(2), primary_key=True), Column('name', String(100)), singlestoredb_table_type=ColumnStore(reference=True), )
ORM Usage:
from sqlalchemy import Column, DateTime, Integer, Numeric, String from sqlalchemy.orm import declarative_base from sqlalchemy_singlestoredb import ColumnStore Base = declarative_base() class Analytics(Base): __tablename__ = 'analytics' id = Column(Integer, primary_key=True) user_id = Column(Integer) event_time = Column(DateTime) amount = Column(Numeric(10, 2)) __table_args__ = { 'singlestoredb_table_type': ColumnStore(), } class CountryCode(Base): '''Reference table replicated to all nodes.''' __tablename__ = 'country_codes' code = Column(String(2), primary_key=True) name = Column(String(100)) __table_args__ = { 'singlestoredb_table_type': ColumnStore(reference=True), }
Methods
__init__([reference, temporary])against(target)Return a copy of this
_schema.ExecutableDDLElementwhich will include the given target.compare(other, **kw)Compare this
_expression.ClauseElementto the given_expression.ClauseElement.compile([bind, dialect])Compile this SQL expression.
execute_if([dialect, callable_, state])Return a callable that will execute this
_ddl.ExecutableDDLElementconditionally within an event handler.execution_options(**kw)Set non-SQL options for the statement which take effect during execution.
get_children(*[, omit_attrs])Return immediate child
visitors.HasTraverseInternalselements of thisvisitors.HasTraverseInternals.get_execution_options()Get the non-SQL options which will take effect during execution.
memoized_instancemethod(fn)Decorate a method memoize its return value.
options(*options)Apply options to this statement.
params([_ClauseElement__optionaldict])Return a copy with
_expression.bindparam()elements replaced.self_group([against])Apply a 'grouping' to this
_expression.ClauseElement.unique_params([_ClauseElement__optionaldict])Return a copy with
_expression.bindparam()elements replaced.Attributes
allows_lambdadescriptionentity_namespaceinherit_cacheIndicate if this
HasCacheKeyinstance should make use of the cache key generation scheme used by its immediate superclass.is_clause_elementis_deleteis_dmlis_from_statementis_insertis_selectis_selectableis_textis_updatestringify_dialectsupports_executiontargetuses_inspectionnegation_clauseproxy_set