我正在尝试使用sqlalchemy执行以下查询。
engine=sqlalchemy.create_engine('mysql+pymysql://root:root@localhost:3306/cst')
cst_delete_query = rf"""delete from customer where STATUS like '%CT%'"""
with engine.connect().execution_options(autocommit=True) as conn:
conn.execute(cst_delete_query)这将导致以下错误:
ValueError: unsupported format character 'C' (0x43) at index 41发布于 2021-02-02 15:39:18
百分号字符是字符串运算符,应进行转义以在字符串中使用。您可以使用第二个%对其进行转义。
cst_delete_query = rf"DELETE FROM customer WHERE status LIKE '%%CT%%'"https://stackoverflow.com/questions/66005294
复制相似问题