ConnectionPool.runQuery returns Transaction.fetchall(). How do I get number of affected rows or last insert id?
Asked
Active
Viewed 788 times
2 Answers
2
You can use the property Transaction.lastrowid
.

Konrad Viltersten
- 36,151
- 76
- 250
- 438

Randell
- 6,112
- 6
- 45
- 70
0
Here's an example of use Transaction to get the last insert id, please refer the question demo code.
You will always get 0 if you do like this in two separate query:
self.dbpool.runQuery('insert into table_x (%s, %s)', ('str1', 'str2'))
self.dbpool.runQuery('select LAST_INSERT_ID()')