MySQL package for python 3.7

后端 未结 4 1113
不知归路
不知归路 2021-02-08 10:23

I am in the need of saving data into a MySQL database, my problem is I can\'t find the package...

Solution explored:

  • Oracle website: https://dev.mysql.c

4条回答
  •  渐次进展
    2021-02-08 10:46

    mysqlclient supports python3.7 officially, you can find it here :

    https://pypi.python.org/pypi/mysqlclient

    1)you can download , PyMySQL 0.9.2
    2)extract & copy the folder pymysql into the python Lib folder
    3)and for connection you can do like this(make a file for example freeman.py):

    #!/usr/bin/env python
    
    import pymysql
    
    conn = pymysql.connect(host='localhost', port=3306, user='root', passwd='', db='freemanDB')
    
    cur = conn.cursor()
    cur.execute("SELECT * FROM users")
    
    print(cur.description)
    print()
    
    for row in cur:
        print(row)
    
    cur.close()
    conn.close()
    

提交回复
热议问题