DbBaseClass

class DbBaseClass(user_config_path='.user_config.ini')[source]

Baseclass for data interactions.

Parameters

user_config_path (str, optional) – Path to the user specific config, which will overwrite default settings. by default “.user_config.ini”

Attributes Summary

default_config_path

Methods Summary

calc_file_hashes

Calculate hashvalues for files.

clean_db

Remove rows where the session work was less than 1min.

get_datetime_now

Helpermethod for mocking of datetime.datetime.now() in unittests.

get_pandas_now

Return datetime.now as pd.Timestamp.

get_remote_db

Download the db_file to db_path_online from the SFTP server.

load_config

Load the config files and sets all necessary properties.

load_db

Read in the db file if it exists or creates a new one.

merge_dbs

Merge local db with remote db.

push_remote_db

Push the db_file from db_path_offline to the SFTP server.

Methods Documentation

calc_file_hashes() DataFrame[source]

Calculate hashvalues for files.

Returns

Dataframe with file hashes.

Return type

pd.DataFrame

clean_db() None[source]

Remove rows where the session work was less than 1min.

get_datetime_now() datetime[source]

Helpermethod for mocking of datetime.datetime.now() in unittests.

Returns

datetime.now()

Return type

datetime.datetime

get_pandas_now() Timestamp[source]

Return datetime.now as pd.Timestamp.

Returns

current time as timestamp: pd.Timestamp

Return type

pd.Timestamp

get_remote_db() bool[source]

Download the db_file to db_path_online from the SFTP server.

This uses the values specified at [“login”][“db_path”] in the config file.

Returns

Whether database retrieval succeeded or not.

Return type

bool

load_config() ConfigParser[source]

Load the config files and sets all necessary properties.

load_db(db_path: str) DataFrame[source]

Read in the db file if it exists or creates a new one.

Parameters

db_path (str) – path to the db_file on the SFTP server

Returns

Loaded database.

Return type

pd.Dataframe

merge_dbs() DataFrame[source]

Merge local db with remote db.

The overlap (same start) is replaced with the max value of end.

Returns

Local db merged with remote db, with striped overlap.

Return type

pd.Dataframe

push_remote_db() bool[source]

Push the db_file from db_path_offline to the SFTP server.

This uses the values specified at [“login”][“db_path”] in the config file.

Returns

Whether database upload succeeded or not.

Return type

bool