0

如果功能如下,我不能使用 True 或 False

case([(table.c.item_id == None, False)], else_= True).label('saved')

查询是使用 sqlalchemy 构建的,但使用此异步库https://github.com/encode/databases执行,该库使用 asyncpg

当我尝试执行它时,它向我显示此错误:

File "asyncpg\protocol\protocol.pyx", line 181, in bind_execute
File "asyncpg\protocol\prepared_stmt.pyx", line 171, in asyncpg.protocol.protocol.PreparedStatementState._encode_bind_msg
asyncpg.exceptions.DataError: invalid input for query argument $3: False (expected str, got bool)

我尝试将它与 sqlalchemy 一起使用,它正确地返回 True/False 值。

engine = create_engine(DATABASE_URL)
conn = engine.connect()
result = conn.execute(query)

asyncpg 有问题吗?我试图用“真”/“假”替换真/假,它正在工作。还有另一种返回布尔值的方法吗?

亲切的问候

4

0 回答 0