搭建py2项目时遇到的sqlalchemy.exc.ArgumentError: columns argument to select() must be a Python list or other

文章讲述了在使用Python2.7的老项目中,尝试初始化DB2数据库时遇到的SQLAlchemy版本问题,具体表现为ArgumentError。解决方案是将SQLAlchemy升级至1.4.11版本。
摘要由CSDN通过智能技术生成

项目是一个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。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值