0

For now my code looks like this:

conn = psycopg2.connect("dbname=monty user=postgres host=localhost password=postgres")
cur = conn.cursor()
cur.execute("SELECT * FROM binance.zrxeth_ob_indicators;")
for row in cur:
  df = pd.DataFrame(row,columns=['timestamp', 'topAsk', 'topBid', 'CPA', 'midprice', 'CPB', 'spread', 'CPA%', 'CPB%'])

But the data are not added to the dataframe, it just creates a new one? Any idea on how to append to the existing same DataFrame? Thanks!

1
  • Do you mean for row in cur.fetchall()? Commented Jan 4, 2019 at 12:19

1 Answer 1

0

Have you tried

df=pd.read_sql_query(“””select * from table “””, conn)

It will read all the the query results directly into a dataframe

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.