2

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?

2
  • 1
    which version of pandas are you using. Commented Jul 20, 2016 at 18:26
  • I checked using print(pd.__version__), it's 0.18.1 Commented Jul 21, 2016 at 8:17

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

3 Comments

In older version of pandas frame_query() is there.
@SaikiHanee You are very welcome. I apologize if I sounded rude to you. I thought the documentation would have been more clear as well.
frame_query and read_frame have been deprecated now there is only read_frame
1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.