zoukankan      html  css  js  c++  java
  • 数据的增删改查

    导入模块

    import pymysql

    conn = pymysql.connect(

    user = "root",

    db = "day36",

    host = "127.0.0.1",

    post = 3306,

    charset = "utf8"

    autocommit = True  #自动提交确认

    )

    cursor = conn.cursor(cursor = pymysql.cursors.DictCursor)

    #以字典形式输出出来

    #获取用户输入的用户名和密码,然后取数据库中校验

    username = input("usename>>:").strip()

    password = input("password>>:").strip()

    sql = select * from userinfo where name = %s and password = %s"

    print(sql)

    sql = "insert into userinfo(name,password,dep_id) values ("jason",789,1)"

    sql = "update userinfo set name = "egons" where id = 6"

    删除

    sql = "delete from userinfo where id = 1"

    res = cursor.execute(sql)

    conn.commit()   #确认当前操作,真正的同步到数据库

    如果真想操作,必须有一步确认操作。

  • 相关阅读:
    浮动 float
    display属性和特性
    盒子阴影
    内边距
    外边距
    边框
    网页背景
    猴子补丁
    设计模式创造者模式--python
    Go语言:validator库对请求参数校验
  • 原文地址:https://www.cnblogs.com/medigrat/p/12050665.html
Copyright © 2011-2022 走看看