I tried to insert name
into database.
name = 'test'
cur.execute("INSERT INTO scholars(name) VALUES('{}') returning id".format(name))
id = cur.fetchone()
print(id)
error message:
psycopg2.IntegrityError: duplicate key value violates unique constraint "idx_16514_primary"
DETAIL: Key (id)=(2321) already exists.
When id=2301
, it succeed,and return ID.
After that,id += 1
and returns the error below.
http://ob9j09f06.bkt.clouddn.com/2016-10-12-16%3A31%3A12.jpg