bug fix: versions of sqlalchemy for meta data

This commit is contained in:
Steve Nyemba 2023-06-16 17:39:02 -05:00
parent 18cd1d8b11
commit aaaf64db33
1 changed files with 8 additions and 2 deletions

View File

@ -106,8 +106,13 @@ class SQLRW :
try:
if self._engine :
table = _args['table'] if 'table' in _args else self.table
if sqlalchemy.__version__.startswith('1.') :
_m = sqlalchemy.MetaData(bind=self._engine)
_m.reflect()
else:
_m = sqlalchemy.MetaData()
_m.reflect(bind=self._engine)
schema = [{"name":_attr.name,"type":str(_attr.type)} for _attr in _m.tables[table].columns]
#
# Some house keeping work
@ -117,6 +122,7 @@ class SQLRW :
_item['type'] = _m[_item['type']]
except Exception as e:
print (e)
pass
return schema
def _tablename(self,name) :