zoukankan      html  css  js  c++  java
  • pymysql操作

    import pymysql

    conn_mysql = pymysql.connect(host='127.0.0.1',port=3306,user='root',password='123456',db="s3")

    cur = conn_mysql.cursor()
    # create_table = 'CREATE TABLE ec2(id INT , NAME VARCHAR(30) )'
    #
    #cur.execute(create_table) #执行sql
    #
    # into_data = 'insert into ec2(id,name) values(2,"B")'

    # cur.execute(into_data)

    cur.execute("SELECT * FROM EC2") #游标必须先查询后cur.fetchone 才能执行
    print(cur.fetchone()) #打印当前游标位置的一条数据

    # many=cursor.fetchmany(3) #打印当前游标位置后3条数据
    # all=cursor.fetchall() #打印当前游标位置后全部数据

    print(cur.fetchone())
    cur.scroll(1,mode="relative") # 相对当前位置移动 当前位置如果是1 向上移动以为 如果是-1向下移动一位
    print(cur.fetchone()) #上面向上移动一位 这里打印的数据就移动到上面去的数据了


    cur.scroll(2,mode="absolute") # 绝对位置移动 直接移动到第二条
    print(cur.fetchone())


    conn_mysql.commit() #提交
    cur.close()
    conn_mysql.close()



  • 相关阅读:
    移动端-纯css隐藏滚动条解决方案
    阻止点击穿透
    JS的防抖与节流
    go 自动安装项目依赖包
    git 修改远程仓库
    git 基础命令
    go 包govalidator
    go email
    windows下Redis的安装和使用
    go xorm,负载均衡
  • 原文地址:https://www.cnblogs.com/ajaxa/p/9257480.html
Copyright © 2011-2022 走看看