io.db.model — Database Models¶
The io.db.model module describes the AutoCNet server databsae models.
New in version 0.1.0.
- class autocnet.io.db.model.ArrayType(*args, **kwargs)[source]¶
Sqlite does not support arrays. Therefore, use a custom type decorator.
See http://docs.sqlalchemy.org/en/latest/core/types.html#sqlalchemy.types.TypeDecorator
- copy()[source]¶
Produce a copy of this
TypeDecoratorinstance.This is a shallow copy and is provided to fulfill part of the
TypeEnginecontract. It usually does not need to be overridden unless the user-definedTypeDecoratorhas local state that should be deep-copied.
- impl¶
alias of
sqlalchemy.sql.sqltypes.String
- process_bind_param(value, dialect)[source]¶
Receive a bound parameter value to be converted.
Subclasses override this method to return the value that should be passed along to the underlying
TypeEngineobject, and from there to the DBAPIexecute()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
Dialectin use.
- process_result_value(value, dialect)[source]¶
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
TypeEngineobject, originally from the DBAPI cursor methodfetchone()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
Dialectin use.
This operation should be designed to be reversible by the “process_bind_param” method of this class.
- class autocnet.io.db.model.IntEnum(enumtype, *args, **kwargs)[source]¶
Mapper for enum type to sqlalchemy and back again
- impl¶
alias of
sqlalchemy.sql.sqltypes.Integer
- process_bind_param(value, dialect)[source]¶
Receive a bound parameter value to be converted.
Subclasses override this method to return the value that should be passed along to the underlying
TypeEngineobject, and from there to the DBAPIexecute()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
Dialectin use.
- process_result_value(value, dialect)[source]¶
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
TypeEngineobject, originally from the DBAPI cursor methodfetchone()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
Dialectin use.
This operation should be designed to be reversible by the “process_bind_param” method of this class.
- class autocnet.io.db.model.Json(*args, **kwargs)[source]¶
Sqlite does not have native JSON support. Therefore, use a custom type decorator.
See http://docs.sqlalchemy.org/en/latest/core/types.html#sqlalchemy.types.TypeDecorator
- impl¶
alias of
sqlalchemy.sql.sqltypes.String
- process_bind_param(value, dialect)[source]¶
Receive a bound parameter value to be converted.
Subclasses override this method to return the value that should be passed along to the underlying
TypeEngineobject, and from there to the DBAPIexecute()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
Dialectin use.
- process_literal_param(value, dialect)[source]¶
Receive a literal parameter value to be rendered inline within a statement.
This method is used when the compiler renders a literal value without using binds, typically within DDL such as in the “server default” of a column or an expression within a CHECK constraint.
The returned string will be rendered into the output string.
New in version 0.9.0.
- process_result_value(value, dialect)[source]¶
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
TypeEngineobject, originally from the DBAPI cursor methodfetchone()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
Dialectin use.
This operation should be designed to be reversible by the “process_bind_param” method of this class.
- property python_type¶
Return the Python type object expected to be returned by instances of this type, if known.
Basically, for those types which enforce a return type, or are known across the board to do such for all common DBAPIs (like
intfor example), will return that type.If a return type is not defined, raises
NotImplementedError.Note that any type also accommodates NULL in SQL which means you can also get back
Nonefrom any type in practice.
- class autocnet.io.db.model.MeasureType(value)[source]¶
Enum to enforce measure type for ISIS control networks