zoukankan      html  css  js  c++  java
  • django写原生sql语句

    执行自定义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()  # 返回结果行游标直读向前,读取一条
    cursor.fetchall()  # 读取所有


  • 相关阅读:
    PHP静态
    PHP批量删除
    PHP增删改查
    PHP数据访问
    PHP继承和多态
    PHP封装
    PHP字符串处理和正则表达式
    PHP数组
    PHP函数
    PHP基础
  • 原文地址:https://www.cnblogs.com/one-tom/p/12053002.html
Copyright © 2011-2022 走看看