MySQL package for python 3.7

后端 未结 4 1107
不知归路
不知归路 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:52

    You must install flask_mysqldb package in order to use MySQL

    pip install flask_mysqldb
    

    To use it:

    from project import app
    
    from flask_mysqldb import MySQL
    

    Config MySQL:

    app.config['MYSQL_HOST'] = 'localhost'
    
    app.config['MYSQL_USER'] = 'root'
    
    app.config['MYSQL_PASSWORD'] = 'yourpassword'
    
    app.config['MYSQL_DB'] = 'mydbfile'
    
    app.config['MYSQL_CURSORCLASS'] = 'MyCursor'
    

提交回复
热议问题