General code clean up for easier debugging.
This commit is contained in:
@@ -38,9 +38,9 @@ def sql_insert(
|
|||||||
table_name: str|None = None,
|
table_name: str|None = None,
|
||||||
rm_id_random: bool = False,
|
rm_id_random: bool = False,
|
||||||
id_random_length: int = 8,
|
id_random_length: int = 8,
|
||||||
|
log_lvl: int = logging.WARNING, # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||||
):
|
):
|
||||||
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
log.setLevel(log_lvl)
|
||||||
log.debug(locals())
|
|
||||||
|
|
||||||
if sql:
|
if sql:
|
||||||
log.info(f'SQL INSERT using sql string.')
|
log.info(f'SQL INSERT using sql string.')
|
||||||
@@ -179,7 +179,6 @@ def sql_update(
|
|||||||
log_lvl: int = logging.WARNING, # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
log_lvl: int = logging.WARNING, # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||||
):
|
):
|
||||||
log.setLevel(log_lvl)
|
log.setLevel(log_lvl)
|
||||||
log.debug(locals())
|
|
||||||
|
|
||||||
if sql:
|
if sql:
|
||||||
sql_update = text(sql)
|
sql_update = text(sql)
|
||||||
@@ -316,9 +315,9 @@ def sql_insert_or_update(
|
|||||||
table_name: str|None = None,
|
table_name: str|None = None,
|
||||||
rm_id_random: bool = False,
|
rm_id_random: bool = False,
|
||||||
id_random_length: int|None = None,
|
id_random_length: int|None = None,
|
||||||
|
log_lvl: int = logging.WARNING, # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||||
):
|
):
|
||||||
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
log.setLevel(log_lvl)
|
||||||
log.debug(locals())
|
|
||||||
|
|
||||||
#if sql: pass
|
#if sql: pass
|
||||||
#else:
|
#else:
|
||||||
@@ -694,10 +693,10 @@ def sql_delete(
|
|||||||
field_name: str|None = None,
|
field_name: str|None = None,
|
||||||
field_value = None,
|
field_value = None,
|
||||||
sql: str|None = None,
|
sql: str|None = None,
|
||||||
data: dict|None = None
|
data: dict|None = None,
|
||||||
|
log_lvl: int = logging.WARNING, # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||||
):
|
):
|
||||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
log.setLevel(log_lvl)
|
||||||
log.debug(locals())
|
|
||||||
|
|
||||||
if table_name and (record_id or record_id_random) and not (field_name or field_value or sql or data):
|
if table_name and (record_id or record_id_random) and not (field_name or field_value or sql or data):
|
||||||
# Delete all records from a table with an ID (auto or random)
|
# Delete all records from a table with an ID (auto or random)
|
||||||
@@ -849,9 +848,9 @@ def redis_lookup_id_random(
|
|||||||
record_id_random: int|str,
|
record_id_random: int|str,
|
||||||
table_name: str,
|
table_name: str,
|
||||||
check_int_id: bool = False,
|
check_int_id: bool = False,
|
||||||
|
log_lvl: int = logging.WARNING, # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||||
) -> str|int|bool|None:
|
) -> str|int|bool|None:
|
||||||
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
log.setLevel(log_lvl)
|
||||||
log.debug(locals())
|
|
||||||
|
|
||||||
if isinstance(record_id_random, str) and len(record_id_random) >= 11 and len(record_id_random) <= 22: pass
|
if isinstance(record_id_random, str) and len(record_id_random) >= 11 and len(record_id_random) <= 22: pass
|
||||||
elif isinstance(record_id_random, int):
|
elif isinstance(record_id_random, int):
|
||||||
@@ -947,10 +946,10 @@ def redis_lookup_id_random(
|
|||||||
@logger_reset
|
@logger_reset
|
||||||
def get_id_random(
|
def get_id_random(
|
||||||
record_id: int,
|
record_id: int,
|
||||||
table_name: str
|
table_name: str,
|
||||||
|
log_lvl: int = logging.WARNING, # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||||
) -> str|bool|None:
|
) -> str|bool|None:
|
||||||
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
log.setLevel(lo_lvl)
|
||||||
log.debug(locals())
|
|
||||||
|
|
||||||
data = { 'id': record_id }
|
data = { 'id': record_id }
|
||||||
sql = f"""
|
sql = f"""
|
||||||
@@ -994,10 +993,10 @@ def get_id_random(
|
|||||||
# This really needs to be simplified... Use a list of dicts instead. Can store as JSON in the DB.
|
# This really needs to be simplified... Use a list of dicts instead. Can store as JSON in the DB.
|
||||||
@logger_reset
|
@logger_reset
|
||||||
def lookup_id_random_pop(
|
def lookup_id_random_pop(
|
||||||
obj_data: dict
|
obj_data: dict,
|
||||||
|
log_lvl: int = logging.WARNING, # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||||
):
|
):
|
||||||
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
log.setLevel(log_lvl)
|
||||||
log.debug(locals())
|
|
||||||
|
|
||||||
if 'account_id_random' in obj_data:
|
if 'account_id_random' in obj_data:
|
||||||
obj_data['account_id'] = redis_lookup_id_random(record_id_random=obj_data['account_id_random'], table_name='account')
|
obj_data['account_id'] = redis_lookup_id_random(record_id_random=obj_data['account_id_random'], table_name='account')
|
||||||
|
|||||||
Reference in New Issue
Block a user