<分区>
我试图将 name
插入数据库。
name = 'test'
cur.execute("INSERT INTO scholars(name) VALUES('{}') returning id".format(name))
id = cur.fetchone()
print(id)
错误信息:
psycopg2.IntegrityError: duplicate key value violates unique constraint "idx_16514_primary"
DETAIL: Key (id)=(2321) already exists.
当id=2301
时,成功,返回ID。
之后,id += 1
并返回以下错误。
http://ob9j09f06.bkt.clouddn.com/2016-10-12-16%3A31%3A12.jpg