欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Python操作postgres数据库

程序员文章站 2022-03-07 22:40:19
...
import psycopg2

conn = psycopg2.connect(database="postgres", user="postgres", password="123456", host="1.1.1.1",
                        port="5432")
cur = conn.cursor()
sql = "CREATE TABLE table_name_2020_08_24 () inherits (table_name)"
cur.execute(sql)
# 提交数据
conn.commit()
# #关闭数据库
cur.close()