Working on conversion to the obj table and everything related to that.

This commit is contained in:
Scott Idem
2024-07-31 17:23:28 -04:00
parent 4145f81850
commit e475ec6686
13 changed files with 1183 additions and 2 deletions

View File

@@ -929,6 +929,7 @@ def sql_select(
def run_sql_select(
sql: str|None = None,
data: dict|None = None,
commit: bool = False,
log_lvl: int = logging.WARNING, # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
) -> None|bool|dict|list:
log.setLevel(log_lvl)
@@ -953,12 +954,18 @@ def run_sql_select(
# https://docs.sqlalchemy.org/en/13/core/sqlelement.html#sqlalchemy.sql.expression.TextClause.columns
# https://docs.sqlalchemy.org/en/13/core/type_basics.html
sql = sql.columns(recurring_start_time=Time, recurring_end_time=Time)
if commit:
trans = db.begin()
if data:
log.info('Executing with SQL statement and data...')
result = db.execute(sql, data)
else:
log.info('Executing with SQL statement only...')
result = db.execute(sql)
if commit:
trans.commit()
except OperationalError as e:
log.error('An operational error exception happened. This is likely a "MySQL server has gone away" error. Going to try again...')
log.exception('**** *** ** * ### BEGIN ### Operational Exception Happened: Trying again... * ** *** ****')
@@ -1037,7 +1044,7 @@ def run_sql_select(
return False # Not successful
else:
log.debug('Successfully executed the SQL on the first try.')
log.info('Successfully executed the SQL on the first try.')
pass
return result
# ### END ### Core Help CRUD ### run_sql_select() ###