versionalchemy package¶
Subpackages¶
Submodules¶
versionalchemy.exceptions module¶
-
exception
versionalchemy.exceptions.
LogTableCreationError
[source]¶ Bases:
exceptions.Exception
Thrown if an invariant is violated when registering a table for versioning with versionalchemy.
versionalchemy.utils module¶
-
class
versionalchemy.utils.
JSONEncodedDict
(*args, **kwargs)[source]¶ Bases:
versionalchemy.utils._JSONEncoded
-
class
versionalchemy.utils.
JSONEncodedList
(*args, **kwargs)[source]¶ Bases:
versionalchemy.utils._JSONEncoded
-
versionalchemy.utils.
generate_and_clause
(cls, row, cols, use_dirty=True)[source]¶ Parameters: - cls – the sqlalchemy ORM model
- row – a sqlalchemy ORM model object (must be an instance of
cls
) - cols – an iterable of strings corresponding to column names
- use_dirty – if
True
(default) will return the dirty value of the column
Returns: a
sqlalchemy.and_()
clause which checks for equality of all columns in cols to the value they contain in row.For example,
generate_and_clause(cls, ['foo', 'bar'], cols) =
would return
sqlalchemy.and_(cls.foo == row.foo, cls.bar == row.bar)
-
versionalchemy.utils.
generate_where_clause
(cls, row, col, use_dirty=True)[source]¶ Parameters: - cls – the sqlalchemy ORM model
- row – a sqlalchemy ORM model object (must be an instance of
cls
) - col – the column name
- use_dirty – if
True
(default) will return the dirty value of the column
Returns: a sqlalchemy
==
clause
-
versionalchemy.utils.
get_bind_processor
(row, col_name, dialect)[source]¶ Returns a bind_processor for the given column in the row based on the dialect. If dialect is None or there is no bind_processor, returns the identity function. The return value of this can be applied to
getattr(row, col_name)
and will return the sql type of that value.
-
versionalchemy.utils.
get_column_attribute
(row, col_name, use_dirty=True, dialect=None)[source]¶ Parameters: - row – the row object
- col_name – the column name
- use_dirty – whether to return the dirty value of the column
- dialect – if not None, should be a
Dialect
. If specified, this function will process the column attribute into the dialect type before returning it; useful if one is using user defined column types in their mappers.
Returns: if
use_dirty
, this will return the value of col_name on the row before it was changed; else this will return getattr(row, col_name)
-
versionalchemy.utils.
get_column_keys
(table)[source]¶ Return a generator of names of the python attribute for the table columns.
-
versionalchemy.utils.
get_column_keys_and_names
(table)[source]¶ Return a generator of tuples k, c such that k is the name of the python attribute for the column and c is the name of the column in the sql table.
-
versionalchemy.utils.
get_column_names
(table)[source]¶ Return a generator of names of the name of the column in the sql table.
-
versionalchemy.utils.
has_constraint
(tbl_name, engine, *col_names)[source]¶ Parameters: - tbl_name – a string with the name of the table to check
- engine – an instance of
sa.engine.Engine
from which to execute the query - col_names – the name of columns which the unique constraint should contain
Return type: Returns: True if the given columns are part of a unique constraint on tbl_name