Python: module ichorORM.model

ichorORM.model | index

`Copyright (c) 2016-2018 Timothy Savannah
Licensed under the terms of the Lesser GNU Lesser General Public License version 2.1
license can be found at https://raw.githubusercontent.com/kata198/ichorORM/master/LICENSE
model.py - ORM model base`

Modules
`` |  |
copy |  |  |

Classes
`` |  | builtins.object DatabaseModel
class DatabaseModel(builtins.object)
`` | `DatabaseModel - Models should extend this`
| Methods defined here: __init__(self, **kwargs) `__init__ - Create an object of this type. Arguments are in form of fieldName=fieldValue` __repr__(self) `__repr__ - Get object representation of this instance @return <str> - A descriptive string of this object` asDict(self, includePk=True) `asDict - Return a dict representation of this model` delete(self, dbConn=None) `delete - Delete current object. Should generally NOT be used, instead things should be "archived" to the best of ability. Will clear the primary key field on this object. If object is already deleted, this will return None @param dbConn <None/DatabaseConnection> Default None- A specific DatabaseConnection to use, if None generate a new connection with global settings @return - Old ID` insertObject(self, dbConn=None, doCommit=True) `insertObject - Inserts current object @param dbConn <None/DatabaseConnection> Default None- A specific DatabaseConnection to use, if None generate a new connection with global settings @param doCommit <bool> default True - If True, will commit upon insert. If False, you must call dbConn.commitTransaction yourself when ready. Primary key is set either way. If doCommit is False, dbConn must be specified (obviously, so you can commit later) Will raise exception if object is already saved, or a REQUIRED_FIELDS is not present.` updateObject(self, updateFieldNames, dbConn=None, doCommit=True) `updateObject - Performs an UPDATE on a given list of field names, based on value held on current object. @param updateFieldNames < list<str> > - A list of field names to update. @param dbConn <None/DatabaseConnection> Default None- A specific DatabaseConnection to use, if None generate a new connection with global settings @param doCommit <bool> default True - If True, will commit upon insert. If False, you must call dbConn.commitTransaction yourself when ready. Primary key is set either way. If doCommit is False, dbConn must be specified (obviously, so you can commit later) Will raise exception if current object is not saved.` Class methods defined here: all(orderByField=None, orderByDir='', dbConn=None) from builtins.type `all - Get all objects associated with this model @param orderByField <None/str> Default None, if provided the list returned will be ordered by this sql field @param orderByDir <str> Default empty string, if provided the list will be ordered in this direction (DESC or ASC) @param dbConn <None/DatabaseConnection> Default None- A specific DatabaseConnection to use, if None generate a new connection with global settings @return list<DatabaseModel> - A list of all objects in the database for this model` createAndSave(replaceSpecialValues=True, dbConn=None, **kwargs) from builtins.type `createAndSave - Creates an object of this type and saves it. Parameters are the fieldName=fieldValue for this model. At least all entries in REQUIRED_FIELDS must be present! @param replaceSpecialValues <bool, default True> - If True, will replace special values ( like NOW() ) with their calculated value. @see QueryBase.replaceSpecialValues for more info. @param dbConn <None/DatabaseConnection> Default None- A specific DatabaseConnection to use, if None generate a new connection with global settings @return - An object of this model's type` filter(whereType='AND', dbConn=None, **kwargs) from builtins.type `filter - Filter and return objects of this type @param whereType <WHERE_AND/WHERE_OR> - Whether filter criteria should be AND or OR'd together @param dbConn <DatabaseConnection/None> default None- If present and not None, will use this as the postgres connection. Otherwise, will start a new connection based on global settings Optionals: @param orderByField - If present, results will be ordered using this field @param orderByDir - If present, ordered results will follow this direction All other parameters should be in the form "fieldName=value" for equality comparison, otherwise fieldName should end with __OPERATION, e.x. fieldName__ne=value for not-equals, fieldName__like="Start%End" for like, etc. @return list<objs> - List of objects of this model type` get(_pk, dbConn=None) from builtins.type `get - Gets a single object of this model type by primary key (id) @param _pk <str/int> - Value of primary key" @param dbConn <None/DatabaseConnection> Default None- A specific DatabaseConnection to use, if None generate a new connection with global settings @return object of this type with all fields populated` Data descriptors defined here: __dict__ `dictionary for instance variables (if defined)` __weakref__ `list of weak references to the object (if defined)` Data and other attributes defined here: DEFAULT_FIELD_VALUES = {} FIELDS = [] PRIMARY_KEY = 'id' REQUIRED_FIELDS = [] SERIAL_PRIMARY_KEY = True TABLE_NAME = None

Data
`` |  | __all__ = ('DatabaseModel',)