maestral.database.types

SQL column type definitions, including conversion rules from / to Python types.

Module Contents

maestral.database.types.T[source]
maestral.database.types.ST[source]
maestral.database.types.ET[source]
class maestral.database.types.SqlType[source]

Bases: Generic[T, ST]

Base class to represent Python types in SQLite table

sql_type = 'TEXT'[source]
sql_to_py(value)[source]

Converts the return value from sqlite3 to the target Python type.

Parameters:

value (ST)

Return type:

T

py_to_sql(value)[source]

Converts a Python value to a type accepted by sqlite3.

Parameters:

value (T)

Return type:

ST

class maestral.database.types.SqlString[source]

Bases: SqlType[str, str]

Class to represent Python strings in SQLite table

sql_type = 'TEXT'[source]
class maestral.database.types.SqlInt[source]

Bases: SqlType[int, int]

Class to represent Python integers in SQLite table

SQLite supports up to 64-bit signed integers (-2**63 < int < 2**63 - 1)

sql_type = 'INTEGER'[source]
class maestral.database.types.SqlFloat[source]

Bases: SqlType[float, float]

Class to represent Python floats in SQLite table

sql_type = 'REAL'[source]
class maestral.database.types.SqlLargeInt[source]

Bases: SqlType[int, str]

Class to represent large integers > 64bit in SQLite table

Integers are stored as text in the database and converted on read / write.

sql_type = 'TEXT'[source]
sql_to_py(value)[source]

Converts the return value from sqlite3 to the target Python type.

Parameters:

value (str)

Return type:

int

py_to_sql(value)[source]

Converts a Python value to a type accepted by sqlite3.

Parameters:

value (int)

Return type:

str

class maestral.database.types.SqlPath[source]

Bases: SqlType[str, bytes]

Class to represent Python paths in SQLite table

Paths are stored as bytes in the database to handle characters in the path which cannot be decoded in the reported file system encoding. On the Python side, paths will contain surrogate escapes in place of such characters.

sql_type = 'BLOB'[source]
sql_to_py(value)[source]

Converts the return value from sqlite3 to the target Python type.

Parameters:

value (bytes)

Return type:

str

py_to_sql(value)[source]

Converts a Python value to a type accepted by sqlite3.

Parameters:

value (str)

Return type:

bytes

class maestral.database.types.SqlEnum(enum)[source]

Bases: SqlType[ET, str]

Class to represent Python enums in SQLite table

Enums are stored as text (attribute name) in the database.

Parameters:

enum (Iterable[ET])

sql_type = 'TEXT'[source]
enum_type[source]
sql_to_py(value)[source]

Converts the return value from sqlite3 to the target Python type.

Parameters:

value (str)

Return type:

ET

py_to_sql(value)[source]

Converts a Python value to a type accepted by sqlite3.

Parameters:

value (ET)

Return type:

str