django写原生sql语句
生活随笔
收集整理的這篇文章主要介紹了
django写原生sql语句
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
執(zhí)行自定義SQL語言:
from django.db import connection ? cursor=connection.cursor() ? # 插入操作 cursor.execute("insert into hello_author(name) values('傳說中的申小五')") ? # 更新操作 cursor.execute("update hello_author set name='abc' where name='bcd'") ? # 刪除操作 cursor.execute("delete from hello_author where name='abc'") ? # 查詢操作 cursor.execute("select * from hello_author") ? raw=cursor.fetchone() # 返回結(jié)果行游標直讀向前,讀取一條 cursor.fetchall() # 讀取所有來源:https://www.cnblogs.com/one-tom/p/12053002.html
與50位技術(shù)專家面對面20年技術(shù)見證,附贈技術(shù)全景圖總結(jié)
以上是生活随笔為你收集整理的django写原生sql语句的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Django运行SQL语句
- 下一篇: RuntimeError at /adm