From cbf641a986e6b6f4b43dd6495456b2cd5a5ff775 Mon Sep 17 00:00:00 2001 From: Steve Nyemba Date: Tue, 22 Sep 2020 13:30:04 -0500 Subject: [PATCH] bug fix with reader --- transport/disk.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/transport/disk.py b/transport/disk.py index 0639086..c36489d 100644 --- a/transport/disk.py +++ b/transport/disk.py @@ -105,6 +105,24 @@ class DiskWriter(Writer): pass finally: DiskWriter.THREAD_LOCK.release() +class SQLiteReader (DiskReader): + def __init__(self,**args) + DiskReader.__init__(self,**args) + self.conn = sqlite3.connect(self.path,isolation_level=None) + self.conn.row_factory = sqlite3.Row + self.table = args['table'] + def read(self,**args): + if 'sql' in args : + sql = args['sql'] + else if 'filter' in args : + sql = "SELECT :fields FROM ",self.table, "WHERE (:filter)".replace(":filter",args['filter']) + sql = sql.replace(":fields",args['fields']) if 'fields' in args else sql.replace(":fields","*") + return = pd.read_sql(sql,self.conn) + def close(self): + try: + self.conn.close() + except Exception as e : + pass class SQLiteWriter(DiskWriter) : def __init__(self,**args):