adding SQLiteDB class 'table_get_record' method
Change-Id: I122805040764e239b61b641f03f03ddd4a677394
Cette révision appartient à :
@@ -76,6 +76,11 @@ class SQLiteDB:
|
||||
self.connection.execute('UPDATE ' + table_name + ' SET tid = ? WHERE "Index" = ?', (tid, rec_id))
|
||||
def change_rec_fld(self, table_name, fld_expr, rec_pat):
|
||||
self.connection.execute('UPDATE ' + table_name + ' SET ' + fld_expr + ' WHERE ' + rec_pat)
|
||||
def table_get_record(self, table_name, rec_pat):
|
||||
cursor = self.connection.execute('SELECT * FROM ' + table_name + ' WHERE ' + rec_pat)
|
||||
raws = cursor.fetchall()
|
||||
if len(raws) != 1: raise Exception('Record (' + rec_pat + ') is not unique, table "' + table_name + '"')
|
||||
return list(raws[0])
|
||||
|
||||
# populate DB table entry
|
||||
def insert_entry(self, table, val_list):
|
||||
@@ -109,8 +114,7 @@ class SQLiteDB:
|
||||
def _get_raw_by_id(self, table_name, rec_id):
|
||||
cursor = self.connection.execute('SELECT * FROM ' + table_name + ' WHERE "Index"=?', (rec_id,))
|
||||
raws = cursor.fetchall()
|
||||
if len(raws) != 1:
|
||||
raise Exception('Index is not unique, table "' + table_name + '"')
|
||||
if len(raws) != 1: raise Exception('Index is not unique, table "' + table_name + '"')
|
||||
return list(raws[0])
|
||||
|
||||
def table_get_raws(self, table_name):
|
||||
|
||||
Référencer dans un nouveau ticket
Bloquer un utilisateur