Types

Column type definitions for sqbooster table schemas.

Each type maps to SQL column types and handles serialization/deserialization.

class sqbooster.types.ColumnType[source]

Bases: object

Base class for all column types.

sql_type = ''
python_type

alias of object

to_sql(value)[source]

Convert a Python value to SQL-compatible format.

from_sql(value)[source]

Convert a SQL value back to Python format.

class sqbooster.types.Integer[source]

Bases: ColumnType

Integer column type. Maps to INTEGER in SQL.

sql_type = 'INTEGER'
python_type

alias of int

to_sql(value)[source]

Convert a Python value to SQL-compatible format.

from_sql(value)[source]

Convert a SQL value back to Python format.

class sqbooster.types.Text(max_length=None)[source]

Bases: ColumnType

Text/string column type. Maps to TEXT/VARCHAR in SQL.

sql_type = 'TEXT'
python_type

alias of str

to_sql(value)[source]

Convert a Python value to SQL-compatible format.

from_sql(value)[source]

Convert a SQL value back to Python format.

class sqbooster.types.Float[source]

Bases: ColumnType

Floating-point column type. Maps to REAL/FLOAT in SQL.

sql_type = 'REAL'
python_type

alias of float

to_sql(value)[source]

Convert a Python value to SQL-compatible format.

from_sql(value)[source]

Convert a SQL value back to Python format.

class sqbooster.types.Boolean[source]

Bases: ColumnType

Boolean column type. Maps to INTEGER (0/1) in SQLite or BOOLEAN in PostgreSQL.

sql_type = 'INTEGER'
python_type

alias of bool

to_sql(value)[source]

Convert a Python value to SQL-compatible format.

from_sql(value)[source]

Convert a SQL value back to Python format.

class sqbooster.types.Blob[source]

Bases: ColumnType

Binary large object column type. Maps to BLOB in SQL. Used for storing pickled Python objects or raw bytes. Non-bytes values are automatically pickled on write.

sql_type = 'BLOB'
python_type

alias of bytes

to_sql(value)[source]

Convert a Python value to SQL-compatible format.

from_sql(value)[source]

Convert a SQL value back to Python format.

class sqbooster.types.Timestamp[source]

Bases: ColumnType

Timestamp column type. Maps to TIMESTAMP in SQL.

sql_type = 'TIMESTAMP'
python_type

alias of str

to_sql(value)[source]

Convert a Python value to SQL-compatible format.

from_sql(value)[source]

Convert a SQL value back to Python format.

class sqbooster.types.Real[source]

Bases: ColumnType

Alias for Float. Maps to REAL in SQL.

sql_type = 'REAL'
python_type

alias of float

to_sql(value)[source]

Convert a Python value to SQL-compatible format.

from_sql(value)[source]

Convert a SQL value back to Python format.

class sqbooster.types.VARCHAR(max_length=255)[source]

Bases: ColumnType

VARCHAR column type with optional max length.

sql_type = 'VARCHAR'
python_type

alias of str

property sql_type_with_length
to_sql(value)[source]

Convert a Python value to SQL-compatible format.

from_sql(value)[source]

Convert a SQL value back to Python format.

class sqbooster.types.JSON[source]

Bases: ColumnType

JSON column type. Stores JSON-serialized data as TEXT in SQLite, native JSONB in PostgreSQL.

sql_type = 'TEXT'
python_type

alias of dict

to_sql(value)[source]

Convert a Python value to SQL-compatible format.

from_sql(value)[source]

Convert a SQL value back to Python format.

class sqbooster.types.Pickle[source]

Bases: ColumnType

Pickle column type. Stores arbitrary Python objects as pickled BLOBs. Use with caution - not portable across Python versions.

sql_type = 'BLOB'
python_type

alias of object

to_sql(value)[source]

Convert a Python value to SQL-compatible format.

from_sql(value)[source]

Convert a SQL value back to Python format.