代码如下 修改xxx即可:
conn = psycopg2.connect(host=DB_SERVICES, user=DB_USERNAME,password=DB_PWD, database=DB_NAME) cur = conn.cursor(cursor_factory=psycopg2.extras.DictCursor) sql = f"select * from xxx.xxx" cur.execute(sql) res = cur.fetchall() pandas.DataFrame([dict(item) for item in res]).to_csv("xxx.csv",index=False,encoding="utf-8")
标签:postgresql,cur,python,表到,xxx,DB,csv,conn From: https://www.cnblogs.com/youmuchen/p/17393129.html