I wrote this function to take in three parameters and a database connection, execute a function, and then pull from a view that is populated by the function.
def get_customer_data(start_date, end_date, segment, con):
""" Get customer data
"""
# This executes a process in the database that populates
# my_view which we will subsequently pull from.
sql = """EXEC PROCESS_POPULATE_VIEW ('%s','%s','%s');
""" % (str(start_date), str(end_date), segment)
con.execute(sql)
sql = "SELECT * FROM MY_VIEW"
return pd.read_sql(sql, con)
This is what I get back:
DatabaseError: (cx_Oracle.DatabaseError) ORA-00900: invalid SQL statement [SQL: "EXEC PROCESS_POPULATE_VIEW ('11-JUN-2018','13-JUN-2018','Carrier');\n "] (Background on this error at: http://sqlalche.me/e/4xp6)
Am I not allowed to call the EXEC command from sqlalchemy? Is there a workaround for this?