local_simple_database package

Submodules

local_simple_database.class_dict_database_handler module

Module with class to handle dict databases

class DictDatabaseHandler(local_dict_database_obj, str_db_name)[source]

Bases: object

This class was built to handle one DICT DataBase

self.local_dict_database_obj

Handler of all DICT database-s in the folder

Type:object of class: LocalDictDatabase
self.str_db_name

Name of DataBase which to use

Type:str
self.default_value

Value to use if key in database is not found

Type:object
change_default_value(new_default_value)[source]

Change default value for exactly one DataBase

Parameters:new_default_value (object) – Value to use if key in database is not found
get_value()[source]

Get current dict value of whole DataBase

set_value(dict_values_to_set)[source]

Setting whole value of DataBase to given dictionary

Parameters:dict_values_to_set (dict) – Any dictionary

local_simple_database.class_local_dict_database module

module with main class to process Local Databases with dictionaries

class LocalDictDatabase(str_path_database_dir='.', float_max_seconds_per_file_operation=0.01, default_value=None, str_datetime_template_for_rolling='')[source]

Bases: local_simple_database.virtual_class_all_local_databases.VirtualAnyLocalDatabase

This class was built to handle dictionary DataBase-s

self.str_path_main_database_dir : str
Path to main folder with DataBase-s
self.str_datetime_template_for_rolling : str
Datetime template for folder name if to use rolling
self.list_supported_types : list
DataBase Types with which this local database can work
self.dict_file_lock_by_fila_path : dict
{file_path_1: FileLock object, …}
self.float_max_seconds_per_file_operation : float
Seconds per file operation, need it for multiprocessing safety
self.default_value

Value to use if key in database is not found

Type:object
self.dict_db_handler_by_str_db_name

{database_name: handler ( special object to handle access to one DB)}

Type:dict
change_default_value(new_default_value)[source]

Changing default value to use for all DICT DataBase-s

Parameters:new_default_value (obj) – Value to use if key in database is not found
init_new_class_obj(**kwargs)[source]

Create a new instance of the same class object

local_simple_database.class_local_simple_database module

Module with class to handle all simple local databases

class LocalSimpleDatabase(str_path_database_dir='.', float_max_seconds_per_file_operation=0.01, str_datetime_template_for_rolling='')[source]

Bases: local_simple_database.virtual_class_all_local_databases.VirtualAnyLocalDatabase

This class was built to handle all one value DataBase-s

self.str_path_main_database_dir : str
Path to main folder with DataBase-s
self.str_datetime_template_for_rolling : str
Datetime template for folder name if to use rolling
self.list_supported_types : list
DataBase Types with which this local database can work
self.dict_file_lock_by_fila_path : dict
{file_path_1: FileLock object, …}
self.float_max_seconds_per_file_operation : float
Seconds per file operation, need it for multiprocessing safety
self.dict_str_db_type_by_str_db_name

{database_1_name: str_value_type, …}

Type:dict
self.dict_list_db_allowed_types_by_str_db_name

{database_1_name: list_allowed_types_for_set_value, …}

Type:dict
self.dict_func_db_getter_by_str_db_name

{database_1_name: func_to_convert_str_to_value, …}

Type:dict
self.dict_func_db_setter_by_str_db_name

{database_1_name: func_to_convert_value_to_str, …}

Type:dict
init_new_class_obj(**kwargs)[source]

Create a new instance of the same class object

init_new_simple_database(str_db_name)[source]

Method for first preparings for new database

Parameters:str_db_name (str) – Name of DataBase which to use

local_simple_database.virtual_class_all_local_databases module

Module with virtual class to contain all common methods for any database

class VirtualAnyLocalDatabase(str_path_database_dir='.', float_max_seconds_per_file_operation=0.01, str_datetime_template_for_rolling='')[source]

Bases: object

This is virtual class to handle all needs for all child DataBases

self.str_path_main_database_dir

Path to main folder with DataBase-s

Type:str
self.str_datetime_template_for_rolling

Datetime template for folder name if to use rolling

Type:str
self.list_supported_types

DataBase Types with which this local database can work

Type:list
self.dict_file_lock_by_file_path

{file_path_1: FileLock object, …}

Type:dict
self.float_max_seconds_per_file_operation

Seconds per file operation, need it for multiprocessing safety

Type:float
define_type_of_db_by_name(str_db_name)[source]

Define type on database if it name follows given template type_name

Parameters:str_db_name (str) – Name of asked database
get_dict_data_by_db_name()[source]

Getting dict with data of every database in the dir of DataBase

get_dict_every_DB_by_datetime()[source]

Getting {date_1: dict_results_of_all_DBs_for_date_1, date_2: …}

get_dir_names_of_all_dirs_with_rolling_DBs()[source]

Getting names of dir-s with rolling results for DataBase

get_file_path_with_db_file(str_db_name)[source]

Get path to file with DataBase

Parameters:str_db_name (str) – Name of asked database
get_folder_for_databases()[source]

Getting folder where should be file with database

get_list_names_of_all_files_with_dbs_in_dir()[source]

Getting all names of databases in DB-handler folder

get_names_of_files_in_dbs_dir()[source]

Get names of files in current directory of DataBase

get_one_db_data_daily(str_db_name, value_to_use_if_db_not_found=None)[source]

Getting {date_1: value_1, date_2: value_2, …} for one database

Parameters:
  • str_db_name (str) – Name of DataBase which to use
  • value_to_use_if_db_not_found (object) – value to set if results for some days not found
read_file_content(str_db_name)[source]

Read whole content of file with DataBase in multiprocess safe way

Parameters:str_db_name (str) – Name of asked database
save_file_content(str_content, str_db_name)[source]

Save content to file with DataBase in multiprocess safe way

Parameters:
  • str_content (str) – Content to save in database file
  • str_db_name (str) – Name of asked database

Module contents

class LocalSimpleDatabase(str_path_database_dir='.', float_max_seconds_per_file_operation=0.01, str_datetime_template_for_rolling='')[source]

Bases: local_simple_database.virtual_class_all_local_databases.VirtualAnyLocalDatabase

This class was built to handle all one value DataBase-s

self.str_path_main_database_dir : str
Path to main folder with DataBase-s
self.str_datetime_template_for_rolling : str
Datetime template for folder name if to use rolling
self.list_supported_types : list
DataBase Types with which this local database can work
self.dict_file_lock_by_fila_path : dict
{file_path_1: FileLock object, …}
self.float_max_seconds_per_file_operation : float
Seconds per file operation, need it for multiprocessing safety
self.dict_str_db_type_by_str_db_name

{database_1_name: str_value_type, …}

Type:dict
self.dict_list_db_allowed_types_by_str_db_name

{database_1_name: list_allowed_types_for_set_value, …}

Type:dict
self.dict_func_db_getter_by_str_db_name

{database_1_name: func_to_convert_str_to_value, …}

Type:dict
self.dict_func_db_setter_by_str_db_name

{database_1_name: func_to_convert_value_to_str, …}

Type:dict
init_new_class_obj(**kwargs)[source]

Create a new instance of the same class object

init_new_simple_database(str_db_name)[source]

Method for first preparings for new database

Parameters:str_db_name (str) – Name of DataBase which to use
class LocalDictDatabase(str_path_database_dir='.', float_max_seconds_per_file_operation=0.01, default_value=None, str_datetime_template_for_rolling='')[source]

Bases: local_simple_database.virtual_class_all_local_databases.VirtualAnyLocalDatabase

This class was built to handle dictionary DataBase-s

self.str_path_main_database_dir : str
Path to main folder with DataBase-s
self.str_datetime_template_for_rolling : str
Datetime template for folder name if to use rolling
self.list_supported_types : list
DataBase Types with which this local database can work
self.dict_file_lock_by_fila_path : dict
{file_path_1: FileLock object, …}
self.float_max_seconds_per_file_operation : float
Seconds per file operation, need it for multiprocessing safety
self.default_value

Value to use if key in database is not found

Type:object
self.dict_db_handler_by_str_db_name

{database_name: handler ( special object to handle access to one DB)}

Type:dict
change_default_value(new_default_value)[source]

Changing default value to use for all DICT DataBase-s

Parameters:new_default_value (obj) – Value to use if key in database is not found
init_new_class_obj(**kwargs)[source]

Create a new instance of the same class object