尝试使用sqlAlchemy与IBM Db2 AS400 (IBM i7.2)数据库配合使用,但在通过sqlAlchemy查询向数据库中添加对象时出现错误。
class Client(Base):
"""
Client Account Schema
"""
__tablename__ = 'client'
client_id = Column('client_id', Integer, primary_key=True, nullable=False)
client_name = Column('client_name', String(200))
client_address = Column('client_name', Text)
input_client_data = {'client_name': 'test', 'client_address': 'client address'}
with conn.db_session() as session:
client = Client(**input_client_data)
session.add(client)
session.commit()
错误 - pyodbc.Cursor对象没有属性'lastrowid'
此外,我们使用IBM i访问ODBC驱动程序连接到Db2。我的连接字符串如下:
ibm_db_sa+pyodbc400://{user}:{password}@{host}:{port}/{database}
- SQLAlchemy版本:1.3.6
- IBM DB SA版本:0.3.5
- Python:3.5
- 平台:Ubuntu 16.04
驱动程序的详细信息 -
[iSeries Access ODBC Driver]
Description=IBM i Access for Linux ODBC Driver
Driver=/opt/ibm/iaccess/lib/libcwbodbc.so
Setup=/opt/ibm/iaccess/lib/libcwbodbcs.so
Driver64=/opt/ibm/iaccess/lib64/libcwbodbc.so
Setup64=/opt/ibm/iaccess/lib64/libcwbodbcs.so
Threading=0
DontDLClose=1
UsageCount=1