Skip to content

Databases

PdmContext.utils.dbconnector.SQLiteHandler

SQLiteHandler(db_name)

db_name: the name of the database to load or create

create_table

create_table()

Create a table with fields Date (datetime) and 3 text fields (target, contextpickle, metadata,value) target is the name of the target values, context pickle contain a Context object in binary form after pickle.dump() metadata, contain users metadate value, contain the last value of target series.

insert_record

insert_record(date, target, context, metadata='')

Inserts a record of DATE,TARGET,Context (after pickle) , Meta data text, Value (which is the last target value from context)

Parameters:

date: The timestamp of the context

target: The target name on which the context was built

context: The Context object

metadata: Text of possible meta data.

get_contex_between_dates

get_contex_between_dates(start_date, end_date, target)

Returns all Context object in list of the specified target between the start and end dates given.

Parameter:

start_date: Begin date of the query objects

end_date: End date of the query objects

target: the target of which the context will be returned

return: A list of from PdmContext.utils.structure.Context objects

get_all_context_by_target

get_all_context_by_target(target)

Returns all Context object in list of the specified target.

Parameter:

target: the target of which the context will be returned

return: A list of from PdmContext.utils.structure.Context objects

PdmContext.utils.dbconnector.InfluxDBHandler

InfluxDBHandler(host='localhost', port=8086, db_name='my_database', measurment_name='my_table')

host: location of host (ip)

port: port where the database is hosted

db_name: Database name

measurment_name: measurment name to be used

insert_record

insert_record(date, target, context, meta_data='')

Create a measurment with fields Date (datetime) and 3 text fields (target, contex (pickle), metadata,value) target is the name of the target values, context pickle contain a Context object in binary form after pickle.dump() metadata, contain users metadate value, contain the last value of target series.

Parameters:

date: Date of the context

target: name of target series (for tag field)

context: context object

meta_data: meta data passed by user

get_contex_between_dates

get_contex_between_dates(start_date, end_date, target)

Returns all Context object in list of the specified target between the start and end dates given.

Parameter:

start_date: Begin date of the query objects

end_date: End date of the query objects

target: the target of which the context will be returned (tag)

return: A list of from PdmContext.utils.structure.Context objects

get_all_context_by_target

get_all_context_by_target(target)

Returns all Context object in list of the specified target.

Parameter:

target: the target of which the context will be returned (tag)

return: A list of from PdmContext.utils.structure.Context objects