carepoint.db package¶
Submodules¶
carepoint.db.carepoint module¶
-
class
carepoint.db.carepoint.
Carepoint
(server, user, passwd, smb_user=None, smb_passwd=None, db_args=None, **engine_args)[source]¶ Bases:
dict
Base CarePoint db connector object
-
BASE
¶ alias of
Base
-
DEFAULT_DB
= 'cph'¶
-
FILTERS
= {'>=': <built-in function ge>, '==': <built-in function eq>, '<=': <built-in function le>, '=': <built-in function eq>, '<': <built-in function lt>, '>': <built-in function gt>}¶
-
create
(model_obj, vals)[source]¶ Wrapper to create a record in Carepoint :param model_obj: Table class to create with :type model_obj:
sqlalchemy.schema.Table
:param vals: Data to create record with :type vals: dict :rtype:sqlalchemy.ext.declarative.Declarative
-
delete
(model_obj, record_id)[source]¶ Wrapper to delete a record in Carepoint :param model_obj: Table class to update :type model_obj:
sqlalchemy.schema.Table
:param record_id: Id of record to manipulate :type record_id: int :return: Whether the record was found, and deleted :rtype: bool
-
find_models
(model_path=None)[source]¶ Traverse registered model directory and import non-loaded modules
-
get_file
(path)[source]¶ Return a file-like object for the SMB path
Parameters: path – :type:`str` SMB path to fetch Returns: :type:`file` File interface object representing remote resource
-
get_next_sequence
(sequence_name, db_name='cph')[source]¶ It generates and returns the next int in sequence Params:
sequence_name:str
Name of the sequence in Carepoint DB db_name:str
Name of DB containing sequence stored procReturns: Integer to use as pk
-
get_pks
(model_obj)[source]¶ Return the Primary keys in the model :param model_obj: Table class to update :type model_obj:
sqlalchemy.schema.Table
:return: Tuple of primary key name strings :rtype: tuple
-
model_path
= '/home/travis/build/LasLabs/python-carepoint/carepoint/db/../models'¶
-
read
(model_obj, record_id, with_entities=None)[source]¶ Get record by id and return the object :param model_obj: Table class to search :type model_obj:
sqlalchemy.Table
:param record_id: Id of record to manipulate :param with_entities: Attributes to rcv from db. None for * :type with_entities: list or None :param with_entities: List of col names to select, None for all :type with_entities: list or None :rtype:sqlalchemy.engine.ResultProxy
-
register_model
(model_obj)[source]¶ Registration logic + append to models struct :param model_obj: Model object to register :type model_obj:
sqlalchemy.ext.declarative.Declarative
-
register_model_dir
(model_path)[source]¶ This function sets the model path to be searched :param model_path: Path of models :type model_path: str
-
search
(model_obj, filters=None, with_entities=None)[source]¶ Search table by filters and return records :param model_obj: Table class to search :type model_obj:
sqlalchemy.schema.Table
:param filters: Filters to apply to search :type filters: dict or None :param with_entities: List of col names to select, None for all :type with_entities: list or None :rtype:sqlalchemy.engine.ResultProxy
-
send_file
(path, file_obj)[source]¶ Send a file-like object to the SMB path
Parameters: - path – :type:`str` SMB path to fetch
- file_obj – :type:`file` File interface object to send to server
Returns: :type:`bool` Success
-
set_iter_refresh
(refresh=True)[source]¶ Toggle flag to search for new models before iteration :param refresh: Whether to refresh before iteration :type refresh: bool
-
update
(model_obj, record_id, vals)[source]¶ Wrapper to update a record in Carepoint :param model_obj: Table class to update :type model_obj:
sqlalchemy.schema.Table
:param record_id: Id of record to manipulate :type record_id: int :param vals: Data to create record with :type vals: dict :rtype:sqlalchemy.ext.declarative.Declarative
-