zoukankan      html  css  js  c++  java
  • pymysql模块

    import pymysql
    
    conn=pymysql.connect(
             host='localhoset',
             port=3306,
             user='root',
             password=''
             database='day46'
             charset='utf8'
    )
        cur=conn.cursor()
    sql='insert into dep(name)values(%s)'
    cur.execute(sql,('yyyy',))
    cur.executemany(sql.[('aa'),('bb'),('ccc')])
    conn.commit()
    cur.closer()
    conn.close()
    
    import pymysql
    #用户输入:egon''-- assasdasdasd
    #用户输入:xxxxx'' or 1=1 --hello
    name=input('name:').strip()
    password=input('password:').strip()
        conn=pymysql.connect(
                    host='localhost',
                    port=3360,
                    user='root'
                    password=' '
                    databaase='day46'
                    charset='utf8’
    )
    cur=conn.cursor()
    #sql='select*from userinfo where user='%s' and password='%s';'%(name,password)
    #print(sql)
    #sql=select *from userinfo where user='egon'--'and password='';'
    #sql='select*from userinfo where user='xxxx' or 1=1--hello 'and password='''';'
    
    
    
    sql='select *from userinfo where user =%s and password=%s;'
    res =cur.execute(sql,(name,password))
    print(res)
    cur.close()
    conn.close()
    if res:
        print('登录成功')
    else:
        print('登录失败')
    

      

    import pymysql
    conn=pymysql.connect(
                hose='localhost',
                port=3306,
                user='root'
                password=''
                database='day46'
                charset='utf8'
    )
    cur=conn.cursor(cursor=pymysql.cursore.DictCursor)
    res=cur.execute('select*from dep;')
    print(res)
    
    print(cur.fetchone())
    print(cur.fetchone())
    print(cur.fetchamany(3))
    print(cur.fetchall())
    
    cur.scroll(6,mode='absolute')#相对绝对位置移动
    print(cur.fetchone())
    cur.scroll(2,mode='absolute')相对绝对位置移动
    print(cur.fetchone())
    
    print(cur.frtchone())
    cur.scroll(1,mode='relative')相对当前位置移动
    print(cur.fetchone())
    cur.scroll(1,mode='relative')
    print(cur.fetchone())
    
    
    print(cur.fetchall())
    cur.scroll(-1,mode='relative')
    print(cur.fetchone())
    cur.execute('insert into dep(name)values('ee');')
    print.commit()
    cur,close()
    conn,close()
    

      

  • 相关阅读:
    MarkDowdPad 破解
    VimFaultException A specified parameter was not correct configSpec.guestId
    did not finish being created even after we waited 189 seconds or 61 attempts. And its status is downloading
    nsx-edge虚拟机抓包实践
    检查子网内存活的主机
    测试防火墙源端口
    vmware创建虚拟机不识别网卡
    ovs-qos配置
    ovs之组网实验
    openstack镜像制作
  • 原文地址:https://www.cnblogs.com/djjv/p/7755245.html
Copyright © 2011-2022 走看看