ORM执行原生SQL语句

from django.db import connection, connections
cursor = connection.cursor()  # cursor = connections['default'].cursor()
cursor.execute("""SELECT * from auth_user where id = %s""", [1])
ret = cursor.fetchone()

有点像pymysql

猜你喜欢

转载自www.cnblogs.com/wt7018/p/11332481.html
今日推荐