创建数据表
最近更新时间: 2024-10-17 17:10:00
#coding=utf-8
#!/usr/bin/python
import psycopg2
try:
conn = psycopg2.connect(database="postgres", user="tbase", password="", host="172.16.0.29", port="15432")
print "连接数据库成功"
cur = conn.cursor()
sql = """
create table tbase
(
id int,
nickname varchar(100)
)distribute by shard(id) to group default_group
"""
cur.execute(sql)
conn.commit()
print "建立数据表成功"
conn.close()
except psycopg2.Error,msg:
print "TBase Error %s" %(msg.args[0])
运行
[tbase@VM_0_29_centos python]$ python createtable.py
#连接数据库成功
#建立数据表成功