DBManager
pyhades.managers.DBManager
(period=1.0, delay=1.0, drop_tables=False)Database Manager class for database logging settings.
set_db
(self, db)Initialize a new DB Object SQLite - Postgres - MySQL
Parameters
- db (db object): Sqlite - Postgres or MySql db object
Returns None
get_db
(self)Returns a DB object
set_dropped
(self, drop_tables)Allows to you set a flag variable to drop database tables when run app.
Parameters
- drop_tables (bool) If True, drop all tables define in the app an initialized it in blank.
Returns
- None
get_dropped
(self)Gets flag variables to drop tables when initialize the app
Return
- drop_tables (bool) Flag variables to drop table
register_table
(self, cls)Allows to you register a new database model
Parameters
- *cls (BaseModel): A class that inherit from BaseModel
create_tables
(self)Creates default tables and tables registered with method register_table
drop_tables
(self)Drop all tables defined
clear_default_tables
(self)If you want initialize any PyHades app without default tables, you can use this method
add_tag
(self, tag, unit, data_type, description, min_value, max_value, tcp_source_address, node_namespace, period)Add tag to tag's repository
get_tags
(self)Gets all tag defined in tag's repository
set_tag
(self, tag, unit, data_type, description, min_value=None, max_value=None, tcp_source_address=None, node_namespace=None)Sets tag to Database
Parameters
- tag (str):
- unit (str):
- data_type (str):
- description (str):
- min_value (float)[Optional]:
- max_value (float)[Optional]:
- tcp_source_address (str)[Optional]:
- node_namespace (str)[Optional]:
set_tags
(self)Allows to you define all tags added with add_tag method
get_table
(self)Gets a dictionary based Class to hold the tags to be logged.
set_period
(self, period)Sets period to log into database
Parameters
- period (float): Time scan to log into database
get_period
(self)Gets the period wich is scan into database
Returns
- period (float): Time scan to log into database
set_delay
(self, delay)Sets an initial time to delay some time before start to logging database
Parameters
- delay (float): Time in seconds to delay before start to logging database
get_delay
(self)Gets time to delay some time before start to logging database
Returns
- delay (float): Time in seconds to delay before start to logging database
init_database
(self)Initializes all databases.
summary
(self)Get database manager summary
Returns
- summary (dict): Database summary