我正在django中执行原始查询,它工作正常。但是,当我在heroku上部署它时,出现了错误。 也许是因为inheroku在postgree上运行,而我做了查询才能在sqlite上运行。 如果我是对的,那么我必须在查询中进行哪些更改才能正常工作?
cursor = connection.cursor()
cursor.execute('''SELECT l_article.id, l_article.lei_id, l_article.article, l_article.is_titulo,
laws_marcacao.is_marcado, laws_marcacao.description, laws_marcacao.votos, accounts_user.id , laws_marcacao.description FROM l_article
INNER JOIN accounts_user
LEFT JOIN laws_marcacao ON laws_marcacao.article_id = l_article.id and laws_marcacao.user_id = accounts_user.id
where l_article.law_id = %s and accounts_user.id = %s;''', [law.id, request.user.id])
data = cursor.fetchall()
那是错误:
Traceback (most recent call last):
File "/app/.heroku/python/lib/python3.7/site-packages/django/db/backends/utils.py", line 85, in _execute
return self.cursor.execute(sql, params)
psycopg2.ProgrammingError: syntax error at or near "where"
LINE 5: where l_article.law_id = 1 and acco...