I am trying to loop through several SQL Queries and append the results for these queries in a dataframe or dictionary with the key being the SQL Query
I was able to retrieve results from these SQL Queries.
from pandas import DataFrame
for index, row in df.iterrows():
cur.execute(row["SQL_Query"])
print(cur.fetchall())
Output:
[(datetime.date(2019, 4, 8), datetime.date(2019, 4, 1))]
[(2, )]
[('6', 2), ('7', 2)]
[(13, 2)]
But when I try to add them to a dataframe, I am only able to fetch result from the last query.
from pandas import DataFrame
for index, row in df.iterrows():
res = cur.execute(row["SQL_Query"])
df['Results'] = DataFrame(cur.fetchall())
The goal right now is only to have results from SQL Queries in different columns. For instance, is the query return Total Count and Failed Count, then that be in 2 different columns.