i am using sqlalchemy 0.8 with mysql 5.5
I have a simple table whose ORM definition looks like this
class TrackingTable(db.Model):
__tablename__ = 'tracking_table'
trackid = db.Column(db.BigInteger,primary_key=True)
custid = db.Column(db.String(20), db.ForeignKey('customer.id'))
tracktime = db.Column(db.DateTime ,nullable=False)
formdata = db.Column(db.String(100),nullable=False)
I am assuming that ( as per the docs) trackid is the primary key with is BIGINT type hence it will get auto incremented.
But when I try to add a record in db
updateRecord = TrackingTable(custid='002',tracktime='2013-02-02',formdata='logged in')
db_session.add(updateRecord)
db_session.flush()
db_session.commit()
It gives a warning Warning: Field 'trackid' doesn't have a default value
And it always takes a value of 0 for trackid, as a result the second addition always fails with error IntegrityError: (IntegrityError) (1062, "Duplicate entry '0' for key 'PRIMARY'") 'INSERT INTO tracking_table (custid, tracktime, formdata)
Pl help me fix this issue. Ideally I would like this to be a incremented value to be handled by database but I cannot figure out how to achieve this.
Thanks in advance