I have been using the following code in production for the last couple of months,
@task
def sql_run_procs():
"""This is a delete and update..."""
# Get our logger
logger = prefect.utilities.logging.get_logger() # type: ignore
conn = connect_db(prefect.config.kv.p.prod_db_constring, logger) ## wrapper around create_engine()
with conn.connect() as con:
try:
r = con.execute(
f"EXECUTE fs.spETL_MyProc '{prefect.config.kv.p.staging_db_name}'"
).fetchall()
for q in r[0]:
if q == 1:
logger.info(f"Query {q} has failed")
raise signals.FAIL()
except :
raise SQLAlchemyError("Error in SQL Script")
So like any good coder I copy and pasted the code into another script
@task
def sql_run_procs():
"""This is a clean, truncate and insert"""
# Get our logger
logger = prefect.utilities.logging.get_logger() # type: ignore
conn = connect_db(prefect.config.kv.p.prod_db_constring, logger)
with conn.connect() as con:
try:
r = con.execute(
f"EXECUTE forms.spETL_MyOtherProc '{prefect.config.kv.p.staging_db_name}'"
).fetchall()
for q in r[0]:
if q == 1:
logger.info(f"Query {q} has failed")
raise signals.FAIL()
except :
raise SQLAlchemyError("Error in SQL Script")
And got the following error:
AttributeError: 'NoneType' object has no attribute 'fetchall'
The only difference other than the name of the stored procedure is they're in different Prefect projects. I've searched this site and others for a possible solution but had no success. I know that it's probably something staring me right in the face but after an hour and a half... you know. Thanks in advance.