Python Pandas read_sql_query “'NoneType' object is not iterable” error

后端 未结 1 1542
时光取名叫无心
时光取名叫无心 2021-01-12 08:15

I am trying to execute a sql and save a result into Panda Dataframe. here is my code.

        dbserver = \'validserver\'
        filename = \'myquery.sql\'
         


        
相关标签:
1条回答
  • 2021-01-12 08:53

    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

    0 讨论(0)
提交回复
热议问题