项目是一个python2.7.5的老项目,pip list如下:
Package Version
---------------- -------------------
certifi 2020.6.20
click 6.2
Flask 0.10.1
Flask-Cors 2.1.2
Flask-SocketIO 0.6.0
gevent 1.0.2
gevent-socketio 0.3.6
gevent-websocket 0.9.5
greenlet 0.4.9
ibm-db 2.0.6
ibm-db-sa 0.4.0
importlib 1.0.3
itsdangerous 0.24
Jinja2 2.8
MarkupSafe 0.23
nose 1.3.7
Pillow 3.1.0
pip 19.3.1
psycopg2 2.6.1
reportlab 3.2.0
setuptools 44.0.0.post20200106
six 1.10.0
SQLAlchemy 1.3.0
Werkzeug 0.10.4
wheel 0.24.0
xlrd 0.9.4
xlutils 1.7.1
xlwt 1.0.0
运行sqlalchemy进行初始化db2数据库时出现以下问题
Traceback (most recent call last):
File "init_db.py", line 19, in <module>
NXBase.metadata.drop_all(engine, checkfirst=True)
File "/home/liuchuang/miniconda3/envs/py2/lib/python2.7/site-packages/sqlalchemy/sql/schema.py", line 4313, in drop_all
ddl.SchemaDropper, self, checkfirst=checkfirst, tables=tables
File "/home/liuchuang/miniconda3/envs/py2/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 2033, in _run_visitor
conn._run_visitor(visitorcallable, element, **kwargs)
File "/home/liuchuang/miniconda3/envs/py2/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1607, in _run_visitor
visitorcallable(self.dialect, self, **kwargs).traverse_single(element)
File "/home/liuchuang/miniconda3/envs/py2/lib/python2.7/site-packages/sqlalchemy/sql/visitors.py", line 131, in traverse_single
return meth(obj, **kw)
File "/home/liuchuang/miniconda3/envs/py2/lib/python2.7/site-packages/sqlalchemy/sql/ddl.py", line 883, in visit_metadata
unsorted_tables = [t for t in tables if self._can_drop_table(t)]
File "/home/liuchuang/miniconda3/envs/py2/lib/python2.7/site-packages/sqlalchemy/sql/ddl.py", line 972, in _can_drop_table
self.connection, table.name, schema=effective_schema
File "/home/liuchuang/miniconda3/envs/py2/lib/python2.7/site-packages/ibm_db_sa/base.py", line 770, in has_table
return self._reflector.has_table(connection, table_name, schema=schema, **kw)
File "/home/liuchuang/miniconda3/envs/py2/lib/python2.7/site-packages/ibm_db_sa/reflection.py", line 189, in has_table
s = sql.select(self.sys_tables.c.tabname).where(whereclause)
File "<string>", line 2, in select
File "<string>", line 2, in __init__
File "/home/liuchuang/miniconda3/envs/py2/lib/python2.7/site-packages/sqlalchemy/util/deprecations.py", line 130, in warned
return fn(*args, **kwargs)
File "/home/liuchuang/miniconda3/envs/py2/lib/python2.7/site-packages/sqlalchemy/sql/selectable.py", line 2923, in __init__
"columns argument to select() must "
sqlalchemy.exc.ArgumentError: columns argument to select() must be a Python list or other iterable
解决方案:
升级sqlalchemy版本到1.4.11。