Sfoglia il codice sorgente

update execute functoin sqlHandler

tsteuer 5 anni fa
parent
commit
360912c7ab
1 ha cambiato i file con 5 aggiunte e 4 eliminazioni
  1. 5 4
      cdplib/db_handlers/SQLHandler.py

+ 5 - 4
cdplib/db_handlers/SQLHandler.py

@@ -217,7 +217,7 @@ class SQLHandler:
         for sub_query in sqlparse.split(query):
             if len(sub_query) > 0:
                 try:
-                   result.append(connection.execute(sub_query, multi=True))
+                   result.append(pd.read_sql(sql=sub_query, con=connection))
                 except Exception as e:
                     errors.append(str(e))
 
@@ -429,7 +429,7 @@ class SQLHandler:
                         self.read_sql_to_dataframe(query).iloc[:, 0].tolist()]
 
         except Exception as e:
-            self._log.warn((
+            self._log.warning((
                 'Could not select columns from '
                 'informational schema. Trying to '
                 'load the table into a dataframe and selec column names.'
@@ -442,7 +442,7 @@ class SQLHandler:
                                tablename)
 
             data = self.execute(query)
-            colnames = data.columns.tolist()
+            colnames = data[0].columns.tolist()
 
         return colnames
 
@@ -641,4 +641,5 @@ class SQLHandler:
             self._engine.dispose()
         except Exception as e:
             print(('An error occured when trying to dispose the SQL engine. Error: {}').format(e))
-            raise Exception(e)
+            raise Exception(e)
+