【发布时间】:2018-09-05 10:36:27
【问题描述】:
有什么方法可以防止在 python peewee (peewee-2.8.8) ORM 中转义反斜杠?
我想在 MySQL 数据库中执行查询:
SHOW MASTER STATUS\G
“\G”部分是必不可少的!我需要垂直形式的结果。
问题在于 peewee 总是转义反斜杠 (\) 所以它在 MySQL 中结束为:
SHOW MASTER STATUS\\G
当然 MySQL 会发出错误:
"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\\G' at line 1"
我尝试使用普通的“execute_sql”方法:
cursor = RaDatabase.execute_sql('SHOW MASTER STATUS\G')
还有“原始”方法:
query = BaseModel.raw('SHOW MASTER STATUS\G')
result = query.execute()
但都以转义字符结尾。
【问题讨论】: