Answers for "write pandas dataframe to postgresql psycopg2"

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

Code answers related to "write pandas dataframe to postgresql psycopg2"

Python Answers by Framework

Browse Popular Code Answers by Language