converters
converters
¶
Type converters for serialising/deserialising Python values to/from SQLite.
Provides bidirectional conversion between Python types (datetime, bool, Enum, list, dict, Pydantic models) and SQLite column values (TEXT, INTEGER, REAL).
Functions¶
serialize_field
¶
Convert a Python value to a SQLite-compatible parameter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
The Python value to serialize. |
required |
annotation
|
Any
|
The type annotation for the field. |
required |
Returns:
| Type | Description |
|---|---|
SQLParam
|
A value suitable for sqlite3 execute() binding. |
Source code in src/marianne/schema/converters.py
deserialize_field
¶
Convert a SQLite value back to the expected Python type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
The raw value from SQLite. |
required |
annotation
|
Any
|
The type annotation for the target field. |
required |
Returns:
| Type | Description |
|---|---|
Any
|
The reconstructed Python value. |