mercredi 27 mai 2015

SQLite - Autoincrement starting from a given value in Python

In python I create a table in SQLite with:

"""CREATE TABLE IF NOT EXISTS ID(ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT NOT NULL)"""

but since I'm creating different databases with same structure that I'm planning to join later, to avoid the pk conflict I want to give a starting value for the increment, like 10000. I've tried to put AUTOINCREMENT=10000 but I got:

    cur.execute("""CREATE TABLE IF NOT EXISTS ID(ID INTEGER PRIMARY KEY AUTOINCREMENT = 10000, NAME TEXT NOT NULL)""")
sqlite3.OperationalError: near "=": syntax error
>>> 

Aucun commentaire:

Enregistrer un commentaire