dlt.destinations.impl.sqlalchemy.type_mapper
SqlalchemyTypeMapper Objects
class SqlalchemyTypeMapper(DataTypeMapper)
Maps dlt data types to SQLAlchemy column types and back.
to_destination_type dispatches to per-type visitor methods named db_type_from<dlt_type>_type (e.g. _db_type_from_json_type). Subclasses can override individual visitors to customize mapping for a single dlt type without reimplementing the full dispatch. Overriding to_destination_type directly is still supported for backward compatibility.
db_type_from_text_type
def db_type_from_text_type(column: TColumnSchema,
table: PreparedTableSchema) -> sqltypes.TypeEngine
Converts dlt "text" — variable-length string, optional precision sets max length.
db_type_from_double_type
def db_type_from_double_type(
column: TColumnSchema,
table: PreparedTableSchema) -> sqltypes.TypeEngine
Converts dlt "double" — 64-bit IEEE 754 floating point.
db_type_from_bool_type
def db_type_from_bool_type(column: TColumnSchema,
table: PreparedTableSchema) -> sqltypes.TypeEngine
Converts dlt "bool" — true/false.
db_type_from_timestamp_type
def db_type_from_timestamp_type(
column: TColumnSchema,
table: PreparedTableSchema) -> sqltypes.TypeEngine
Converts dlt "timestamp" — date and time with optional timezone and fractional seconds.
db_type_from_bigint_type
def db_type_from_bigint_type(
column: TColumnSchema,
table: PreparedTableSchema) -> sqltypes.TypeEngine
Converts dlt "bigint" — integer with optional precision (16, 32, 64 bits).
db_type_from_binary_type
def db_type_from_binary_type(
column: TColumnSchema,
table: PreparedTableSchema) -> sqltypes.TypeEngine
Converts dlt "binary" — raw bytes, optional precision sets max length.
db_type_from_json_type
def db_type_from_json_type(column: TColumnSchema,
table: PreparedTableSchema) -> sqltypes.TypeEngine
Converts dlt "json" — arbitrary nested JSON data.
db_type_from_decimal_type
def db_type_from_decimal_type(
column: TColumnSchema,
table: PreparedTableSchema) -> sqltypes.TypeEngine
Converts dlt "decimal" — arbitrary-precision decimal number.
db_type_from_wei_type
def db_type_from_wei_type(column: TColumnSchema,
table: PreparedTableSchema) -> sqltypes.TypeEngine
Converts dlt "wei" — large-precision integer for blockchain wei values.
db_type_from_date_type
def db_type_from_date_type(column: TColumnSchema,
table: PreparedTableSchema) -> sqltypes.TypeEngine
Converts dlt "date" — calendar date without time component.
db_type_from_time_type
def db_type_from_time_type(column: TColumnSchema,
table: PreparedTableSchema) -> sqltypes.TypeEngine
Converts dlt "time" — time of day with optional timezone and fractional seconds.
JSONString Objects
class JSONString(sa.TypeDecorator)
Custom SQLAlchemy type that stores JSON data as a string in the database.
Automatically serializes Python objects to JSON strings on write and deserializes JSON strings back to Python objects on read.