database_connections package

Subpackages

Submodules

database_connections.DatabaseConnection module

class database_connections.DatabaseConnection.DatabaseConnection(**kwargs)[source]

Bases: ParentClass

extra keyword agrugments will be set according to each SQL service’s requirements This class should only be used as a parent class for other specific sql services

execute(string, **kwargs)[source]

execute the given string

exit()[source]
get_cursor(**kwargs)[source]

get the cursor from the connection

init(**kwargs)[source]

sets attributes, gets connection, and prints attributes

print_all_atts(print_off=True)[source]

Print off all Class instance attributes

print_imp_atts(**kwargs)[source]

Prints off (or returns a string) with the ‘important’ information about a class Most child classes will redefine this method with custom attributes to print off

print_one_line_atts(**kwargs)[source]

Prints off (or returns a string) with information about a class in one line Most child classes will redefine this method with custom attributes to print off

query(query_string='', query_file=None, **kwargs)[source]

query the connection via the string or file

write(df, table_name, **kwargs)[source]

given the pandas DF, table_name, and other kwargs, write to database connection

database_connections.Query module

class database_connections.Query.Query(string='', query_path='', export_path='', engine='sqlite', query_Path=None, export_Path=None, conn_inst=None, **connection_module_params)[source]

Bases: ParentClass

A Python class for SQL Queries Query class is agnostic of engine

execute()[source]

execute a command / statement

export(**kwargs)[source]

export the df returned by the query to given export_Path

get_unique_export_Path()[source]

make sure the export Path is unique

get_unique_query_Path()[source]

make sure the query Path is unique

print_imp_atts(print_off=True)[source]

Prints off (or returns a string) with the ‘important’ information about a class Most child classes will redefine this method with custom attributes to print off

print_one_line_atts(print_off=True, leading_string='\t')[source]

Prints off (or returns a string) with information about a class in one line Most child classes will redefine this method with custom attributes to print off

query(export=False, **kwargs)[source]

run the query using the module.query(), returns pandas DataFrame

read_string_from_path()[source]

read the contents of the filepath

save()[source]

using the query string, export to query_Path

database_connections.TJEncryptPassword module

database_connections.TJEncryptPassword.createEncryptedPasswordFile(sTransformation, sAlgorithm, sMode, sPadding, sMatch, abyKey, sMac, abyMacKey, sEncPassFileName, sPassword)[source]
database_connections.TJEncryptPassword.createPasswordEncryptionKeyFile(sTransformation, sAlgorithm, sMode, sPadding, nKeySizeInBits, sMatch, sMac, sPassKeyFileName)[source]
database_connections.TJEncryptPassword.decryptPassword(sPassKeyFileName, sEncPassFileName)[source]
database_connections.TJEncryptPassword.j2p(sName)[source]
database_connections.TJEncryptPassword.loadPropertiesFile(sFileName)[source]

database_connections.password_encryption module

database_connections.password_encryption.custom_decrypt(sPassKeyFileName, sEncPassFileName)[source]
database_connections.password_encryption.custom_encrypt(raw_password, passkey_path, encpass_path)[source]

database_connections.sql_support_functions module

database_connections.sql_support_functions.get_DatabaseConnection(connection_module='sqlite', **kwargs)[source]

returns a class object from the given SQL connection module

database_connections.sql_support_functions.list_to_string(iterable, sep=',', quotes="'")[source]

Given a list [ ‘meter1’, ‘meter2’, ‘meter3’ ] spits out ‘1234’,’2345’,’3456’

database_connections.sql_support_functions.run_queries_in_folder(queries_Dir, export_Dir, conn_inst, print_df: bool = True, export_type='csv', parquet_engine='fastparquet', file_endings=['sql'])[source]

Given a Dir of Queries, an Export Dir, and a database connection, run all queries as specified by the user

Module contents