bug fix: issue with sqlalchemy & python 3.12

v2.4
Steve Nyemba 2 months ago
parent 6637405898
commit 0dbb0a38e5

@ -3,7 +3,7 @@ This file encapsulates common operations associated with SQL databases via SQLAl
""" """
import sqlalchemy as sqa import sqlalchemy as sqa
from sqlalchemy import text , MetaData, Table from sqlalchemy import text , MetaData, inspect
import pandas as pd 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] # _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 _inspector = inspect(self._engine)
metadata = MetaData() _columns = _inspector.get_columns(_table)
_schema = [{'name':column['name'],'type':str(column['type']) } for column in _columns]
# 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}")
return _schema return _schema
def has(self,**_args): def has(self,**_args):
return self.meta(**_args) return self.meta(**_args)

Loading…
Cancel
Save