zoukankan      html  css  js  c++  java
  • 关于MySQL中pymysql安装的问题。

    一 一般情况下我们直接在终端输入:

    pip3 install pymysql

    就能够自动安装成功。

    但是有时候我们必须先指定一个python解释器:

    比如我们指定python3
    在终端cmd输入:python3  -m pip install pymysql
    就行了。。。。。。。。。。。

     等安装成功之后,我们就可以在pycahrm中直接import pymysql导入啦:

    import pymysql #pip3 install pymysql
    
    conn=pymysql.connect(
        host='127.0.0.1',
        port=3306,
        user='root',
        password='123',
        database='db42',
        charset='utf8'
    )
    cursor=conn.cursor(pymysql.cursors.DictCursor)
    
    # rows=cursor.execute('show tables;')
    rows=cursor.execute('select * from class;')
    print(rows)
    
    
    # print(cursor.fetchone())
    # print(cursor.fetchone())
    # print(cursor.fetchmany(2))
    # print(cursor.fetchall())
    # print(cursor.fetchall())
    
    
    # print(cursor.fetchall())
    # cursor.scroll(3,'absolute')
    # print(cursor.fetchone())
    
    print(cursor.fetchone())
    print(cursor.fetchone())
    cursor.scroll(1,'relative')
    print(cursor.fetchone())
    
    cursor.close()
    conn.close()
    
    
    
    
    
    
    

      

  • 相关阅读:
    leetcode刷题37
    leetcode刷题36
    leetcode刷题38
    leetcode刷题35
    leetcode刷题34
    leetcode刷题33
    记一次Unity使用XNode插件时自动连线问题
    Unity中UGUI图片跟随文本自适应
    Unity中多个物体交换位置
    使用VSCode编译C
  • 原文地址:https://www.cnblogs.com/zhangsanfeng/p/9027026.html
Copyright © 2011-2022 走看看