From 29f41330cab26e2f3405f38a0416a0fce793f0e6 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Wed, 17 Jun 2020 03:33:58 -0500 Subject: [PATCH] adding SQLiteDB class 'table_get_record' method Change-Id: I122805040764e239b61b641f03f03ddd4a677394 [ROCm/rocprofiler commit: d0a736689711ba016b6fe3efe94cd204a0b0fda1] --- projects/rocprofiler/bin/sqlitedb.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/projects/rocprofiler/bin/sqlitedb.py b/projects/rocprofiler/bin/sqlitedb.py index eb584503b2..19a8aac3e1 100644 --- a/projects/rocprofiler/bin/sqlitedb.py +++ b/projects/rocprofiler/bin/sqlitedb.py @@ -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):