piecash.sa_extra module — Python interface to GnuCash documents 0.15.0 documentation

# piecash.sa_extra module

`piecash.sa_extra.` `compile_datetime`(element, compiler, **kw)

  data type for the date field

  note: it went from TEXT(14) in 2.6 to TEXT(19) in 2.8 to accommodate for the new ISO format of date in sqlite

`piecash.sa_extra.` `mapped_to_slot_property`(col, slot_name, slot_transform=<function <lambda>>)

  Assume the attribute in the class as the same name as the table column with “_” prepended

`piecash.sa_extra.` `pure_slot_property`(slot_name, slot_transform=<function <lambda>>, ignore_invalid_slot=False)

  Create a property (class must have slots) that maps to a slot

  Parameters: | slot_name – name of the slot slot_transform – transformation to operate before assigning value ignore_invalid_slot – True if incorrect values (usually due to deleted data) should be converted to None
  Returns: |

`piecash.sa_extra.` `get_foreign_keys`(metadata, engine)

  Retrieve all foreign keys from metadata bound to an engine :param metadata: :param engine: :return:

class `piecash.sa_extra.` `ChoiceType`(choices, **kw)

  Bases: `sqlalchemy.sql.type_api.TypeDecorator`

  `process_bind_param`(value, dialect)

    Receive a bound parameter value to be converted.

    Subclasses override this method to return the value that should be passed along to the underlying `TypeEngine` object, and from there to the DBAPI `execute()` method.

    The operation could be anything desired to perform custom behavior, such as transforming or serializing data. This could also be used as a hook for validating logic.

    This operation should be designed with the reverse operation in mind, which would be the process_result_value method of this class.

    Parameters: | value – Data to operate upon, of any type expected by this method in the subclass. Can be `None`. dialect – the `Dialect` in use.

  `process_result_value`(value, dialect)

    Receive a result-row column value to be converted.

    Subclasses should implement this method to operate on data fetched from the database.

    Subclasses override this method to return the value that should be passed back to the application, given a value that is already processed by the underlying `TypeEngine` object, originally from the DBAPI cursor method `fetchone()` or similar.

    The operation could be anything desired to perform custom behavior, such as transforming or serializing data. This could also be used as a hook for validating logic.

    Parameters: | value – Data to operate upon, of any type expected by this method in the subclass. Can be `None`. dialect – the `Dialect` in use.

    This operation should be designed to be reversible by the “process_bind_param” method of this class.