【发布时间】:2020-06-30 20:32:24
【问题描述】:
我刚刚开始深入研究 django 中的原始查询。
我正在尝试更改我的 postgres 中的架构名称,但我的 SQL 查询不起作用
这是我在django shell 中运行的代码:
>>> from django.db import connection
>>> cursor = connection.cursor()
>>> query = "ALTER SCHEMA %s RENAME TO %s;"
>>> data = ('thor', 'thor1')
>>> cursor.execute(query, data)
错误:
django.db.utils.ProgrammingError: syntax error at or near "'thor'"
LINE 1: ALTER SCHEMA 'thor' RENAME TO 'thor1';
我相信那些quotes 是我问题的根源。
知道我该怎么做吗?
【问题讨论】:
标签: sql django postgresql