我有以下代码
from sqlalchemy import *
from sqlalchemy.orm import *
engine = create_engine("postgresql+psycopg2://test:password@localhost/test")
Session = sessionmaker(bind=engine)
session = Session()
metadata = MetaData()
metadata.bind = engine
table = Table('test_table', metadata, autoload = True)
a = session.query(table).filter(table.c.id.in_['1', '2'])
这是遇到的错误。
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'instancemethod' object is unsubscriptable
我确信这是我做错的事情,因为我是 python 新手。提前谢谢你(我很确定这是一个菜鸟错误)