Browse Source

SQL datasource: use Cursor.lastrowid instead of an SQL query

ArnAud 9 years ago
parent
commit
04aa093ccf
1 changed files with 1 additions and 4 deletions
  1. 1
    4
      leobject/datasources/ledatasourcesql.py

+ 1
- 4
leobject/datasources/ledatasourcesql.py View File

@@ -49,10 +49,7 @@ class LeDataSourceSQL(DummyDatasource):
49 49
                 if cur.execute(insert(self.datasource_utils.objects_table_name, object_datas)) != 1:
50 50
                     raise RuntimeError('SQL error')
51 51
 
52
-                if cur.execute('SELECT last_insert_id() as lodel_id') != 1:
53
-                    raise RuntimeError('SQL error')
54
-
55
-                lodel_id, = cur.fetchone()
52
+                lodel_id = cur.lastrowid
56 53
 
57 54
                 datas[self.datasource_utils.field_lodel_id] = lodel_id
58 55
                 query_table_name = self.datasource_utils.get_table_name_from_class(leclass.__name__)

Loading…
Cancel
Save