标签:
import psycopg2 conn = psycopg2.connect(database="baoxin", user="odoo", password="odoo", host="127.0.0.1", port="5432") cur = conn.cursor() cur.execute("CREATE TABLE test(id serial PRIMARY KEY, num integer,data varchar);") cur.execute("SELECT * FROM product_category;") rows = cur.fetchall() # all rows in table print(rows) for i in rows: print(i) conn.commit() cur.close() conn.close()
标签:
原文地址:http://www.cnblogs.com/hltswd/p/5790824.html