【发布时间】:2021-12-11 16:55:27
【问题描述】:
如何通过两个参数在数据库中查找值:
info = db.execute (
f "SELECT * FROM 'storage_users' WHERE status =?, Type =?", [status, Type]
)
【问题讨论】:
标签: python telegram-bot mysql-python
如何通过两个参数在数据库中查找值:
info = db.execute (
f "SELECT * FROM 'storage_users' WHERE status =?, Type =?", [status, Type]
)
【问题讨论】:
标签: python telegram-bot mysql-python
我建议您使用某种 ORM,例如 peewee 或 sqlalchemy 与程序中的数据库进行交互,因为它使与数据库的交互变得更加容易。
为了回答您的问题,我认为您可以尝试以下方法:
f "SELECT * FROM 'storage_users' WHERE status ='{status}', Type ='{Type}'"
【讨论】:
info = db.execute (
f "SELECT * FROM 'storage_users' WHERE status = ? AND Type =?", [status, Type]
)
布尔运算符用于连接数据库查询中需要的两个条件。
【讨论】: