Skip to content Skip to sidebar Skip to footer

Twisted Adbapi: Runinteraction Last_insert_id()

class MySQL(object): def __init__(self): self.dbpool = adbapi.ConnectionPool( 'MySQLdb', db='dummy', user='root', passw

Solution 1:

The last id will be the last inserted row's id in the same transaction.

I have test it use the following operations:

  1. begin a transaction and insert a row use the runInteraction(...) function

  2. get the last insert id, e.g. it is 18

  3. sleep 30 seconds in the function where transaction runs

  4. insert a row to the same table use mysql client or phpMyAdmin

  5. get the last insert id from step 4, e.g. it is 19

  6. sleeping function returns and query the last insert id use the same Transaction object again, the last insert id is still 18

Post a Comment for "Twisted Adbapi: Runinteraction Last_insert_id()"