我的代码如下:
qry = ('select balancer_security.id, balancer_security.name, balancer_security.symbol, '
'balancer_securityprice.at_dt, balancer_securityprice.price, balancer_securityprice.notes '
'from balancer_security LEFT OUTER JOIN balancer_securityprice '
'ON (balancer_security.id = balancer_securityprice.security_id '
'AND balancer_securityprice.at_dt="?") '
# 'AND balancer_securityprice.at_dt="%s") '
'ORDER BY balancer_security.name')
from django.db import connection
cursor = connection.cursor()
cursor.execute(qry, [date])
solution = cursor.fetchall()
cursor.execute行发生错误。 date 是一个包含值 2017-10-05
的字符串此外,参数是在django中放入查询还是传递给SQLite(即我的参数占位符是%s还是?)?
谢谢!
答案 0 :(得分:1)
只需在没有引号的情况下使用它。将"%s"
更改为%s
。