Answers for "python psycopg2 to dataframe"

2

how to save query data into dataframe pscopg2

import pandas as pd
import pandas.io.sql as sqlio
import psycopg2

conn = psycopg2.connect("host='{}' port={} dbname='{}' user={} password={}".format(host, port, dbname, username, pwd))
sql = "select count(*) from table;"
dat = sqlio.read_sql_query(sql, conn)
conn = None
Posted by: Guest on June-30-2020

Python Answers by Framework

Browse Popular Code Answers by Language