It is still not clear why the request returned an inaccurate ID. However, I seem to have dealt with the problem by getting the connection object, rather than using implicit / non-contact execution. Perhaps this was a grasp of two different compounds before and, therefore, providing inconsistent results:
conn = g.engine.connect() query = text("""INSERT INTO HR_PunchBatch (StoreID, UserID, Source,Timestamp,Status) VALUES (:StoreID,:UserID,:Source,NOW(),:Status)""") conn.execute(query, StoreID=StoreID, UserID=session['UserID'], Source=source, Status='New') batch_id = conn.execute('SELECT LAST_INSERT_ID() AS id').fetchone() return batch_id['id']
source share