1. 程式人生 > >Python連線單機版資料庫(Postgresql資料庫)並實現資料提取

Python連線單機版資料庫(Postgresql資料庫)並實現資料提取

import pandas as pd
import psycopg2
conn=psycopg2.connect(database="****", user="postgres", password="***", port="5432")
with conn:
    cur=conn.cursor()
    cur.execute("select * from public.20160407_1")
    rows = cur.fetchall()
    t=pd.DataFrame(rows)