Skip to content Skip to sidebar Skip to footer

Flask-sqalchemy And Oracle Database Id Not Autoincrement

I want to make a new table in my database (Oracle 11g but the Express Edition for Ubuntu 16.04) using Python and Flask framework with the SQLAlchemy module. The first field of the

Solution 1:

You can find here the SQLAlchemy documentation that discusses this. Oracle has no auto increment feature and relies on sequence to mimic the behavior.

So, your id column should look like this:

id_seq = Sequence('id_seq')
id = db.Column(db.Integer, id_seq,
        server_default=id_seq.next_value(), primary_key=True)

Post a Comment for "Flask-sqalchemy And Oracle Database Id Not Autoincrement"