Skip to main content
Version: 1.31.0 (latest)

dlt.destinations.impl.sqlalchemy.type_mapper

SqlalchemyTypeMapper Objects​

class SqlalchemyTypeMapper(DataTypeMapper)

View source on GitHub

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

View source on GitHub

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

View source on GitHub

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

View source on GitHub

Converts dlt "bool" — true/false.

db_type_from_timestamp_type​

def db_type_from_timestamp_type(
column: TColumnSchema,
table: PreparedTableSchema) -> sqltypes.TypeEngine

View source on GitHub

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

View source on GitHub

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

View source on GitHub

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

View source on GitHub

Converts dlt "json" — arbitrary nested JSON data.

db_type_from_decimal_type​

def db_type_from_decimal_type(
column: TColumnSchema,
table: PreparedTableSchema) -> sqltypes.TypeEngine

View source on GitHub

Converts dlt "decimal" — arbitrary-precision decimal number.

db_type_from_wei_type​

def db_type_from_wei_type(column: TColumnSchema,
table: PreparedTableSchema) -> sqltypes.TypeEngine

View source on GitHub

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

View source on GitHub

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

View source on GitHub

Converts dlt "time" — time of day with optional timezone and fractional seconds.

JSONString Objects​

class JSONString(sa.TypeDecorator)

View source on GitHub

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.

This demo works on codespaces. Codespaces is a development environment available for free to anyone with a Github account. You'll be asked to fork the demo repository and from there the README guides you with further steps.
The demo uses the Continue VSCode extension.

Off to codespaces!

DHelp

Ask a question

Welcome to "Codex Central", your next-gen help center, driven by OpenAI's GPT-4 model. It's more than just a forum or a FAQ hub – it's a dynamic knowledge base where coders can find AI-assisted solutions to their pressing problems. With GPT-4's powerful comprehension and predictive abilities, Codex Central provides instantaneous issue resolution, insightful debugging, and personalized guidance. Get your code running smoothly with the unparalleled support at Codex Central - coding help reimagined with AI prowess.