Lanms Blog

python3连接postgresql
Publish: 2019/3/29   

python3连接postgresql

import psycopg2


host = '127.0.0.1'
port = 5432
user = 'postgres'
password = '123456'
dbname = 'test'


conn = psycopg2.connect(dbname=dbname, user=user,
                        password=password, host=host, port=port)

cur = conn.cursor()

cur.execute('select * from testcase;')

result = cur.fetchall()
print(result)


← 责任链模式 命令模式 →

Powered by Hexo, Theme designs by @hpcslag.
Style-Framework Tocas-UI designs by @yamioldmel