AttributeError: module 'pandas.io.sql' has no attribute 'frame_query'

10,576

Solution 1

Looking at the pandas.io.sql source, there is no frame_query.

https://github.com/pydata/pandas/blob/master/pandas/io/sql.py

Documentation for pandas.io.sql is here: http://pandas.pydata.org/pandas-docs/stable/io.html#sql-queries


I've looked at pandas documentation from 0.12.0 to latest and the only references to frame_query I've found has been to its deprecation.

I found this SO answer which may address your concerns: https://stackoverflow.com/a/14511960/1703772

However, if you are using pandas version ~ 0.10 when 0.18.1 is available, I have to ask why.

Solution 2

Such approach is deprecated,

https://pandas.pydata.org/pandas-docs/version/0.15.2/generated/pandas.io.sql.write_frame.html

use instead: https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.to_sql.html

Share:
10,576
SaikiHanee
Author by

SaikiHanee

Updated on June 04, 2022

Comments

  • SaikiHanee
    SaikiHanee almost 2 years

    I am trying to read a posgresql table into a python data frame using following code.

    import psycopg2 as pg
    import pandas.io.sql as psql
    
    connection = pg.connect("dbname=BeaconDB user=admin password=root")
    dataframe = psql.frame_query("SELECT * from encounters", connection)
    

    But I get AttributeError: module 'pandas.io.sql' has no attribute 'frame_query' How can I fix this?

  • shivsn
    shivsn almost 8 years
    In older version of pandas frame_query() is there.
  • NuclearPeon
    NuclearPeon almost 8 years
    @SaikiHanee You are very welcome. I apologize if I sounded rude to you. I thought the documentation would have been more clear as well.
  • cardamom
    cardamom about 6 years
    frame_query and read_frame have been deprecated now there is only read_frame