Cursor.execute没有崩溃

时间:2018-10-30 12:11:48

标签: python django

cursor.execute(query)在Django中未执行,如果我已使用sqldeveloper在oracle中输入了元组手册。

        with connection.cursor() as cursor:
            try:
                print(value)
                print(username)
                cursor.execute("Select * from users where id=1")
            finally:
                cursor.close()

2 个答案:

答案 0 :(得分:0)

使用下面的代码。

from django.db import connection
cursor = connection.cursor()
cursor.execute("SELECT * Table ")
results = cursor.fetchall()

答案 1 :(得分:0)

我认为您遇到了以下错误:AttributeError: __enter__。 这个错误意味着您不能将语句with .. as ..conn.cursor()

一起使用