diff --git a/transport/sql/common.py b/transport/sql/common.py index a6a1a0f..e10a374 100644 --- a/transport/sql/common.py +++ b/transport/sql/common.py @@ -3,7 +3,7 @@ This file encapsulates common operations associated with SQL databases via SQLAl """ import sqlalchemy as sqa -from sqlalchemy import text , MetaData, Table +from sqlalchemy import text , MetaData, inspect import pandas as pd @@ -51,16 +51,9 @@ class Base: # _schema = [{"name":_attr.name,"type":_map.get(str(_attr.type),str(_attr.type))} for _attr in _handler.tables[_table].columns] # - # Step 2: Create a MetaData object - metadata = MetaData() - - # Step 3: Reflect the table - table = Table(_table, metadata, autoload_with=self._engine) - - # Step 4: Print the column names and their types - _schema = [{"name":column.name,"type":_map.get(str(column.type),str(column.type))} for column in table.columns] - # _schema - # print(f"name: {column.name, Type: {column.type}") + _inspector = inspect(self._engine) + _columns = _inspector.get_columns(_table) + _schema = [{'name':column['name'],'type':str(column['type']) } for column in _columns] return _schema def has(self,**_args): return self.meta(**_args)