小小疯子

导航

 

Django中能用ORM的就用它ORM吧,不建议执行原生SQL,可能会有一些安全问题,

如果实在是SQL太复杂ORM实现不了,那就看看下边执行原生SQL的方法,跟直接使用pymysql基本一致了

from  django.db  import connection

with connection.cursor() as cursor

  cursor.excute('select * from accounts_User')

  row = cursor.fetchall()

return row

posted on 2018-08-25 23:11  小小疯子1  阅读(1163)  评论(0编辑  收藏  举报