I am trying to execute a sql and save a result into Panda Dataframe. here is my code.
dbserver = \'validserver\'
filename = \'myquery.sql\'
From what I understand, read_sql_query()
would only return the results from your first statement anyhow. In which case, it's SET NOCOUNT ON;
and as you can see, will return None
, which is why your code failed. IMO You should be optimizing your SQL statement to return one table instead of multiple in the process (as you only want to read from #final I assume).
If you really want to have multiple sql query in a dataframe, you can use lists
and split
as mentioned in this thread:
Pandas read_sql query with multiple selects