📜  如何将查询数据保存到数据框 pscopg2 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:36.815000             🧑  作者: Mango

代码示例1
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