Using MySQL in Flask

前端 未结 8 806
忘掉有多难
忘掉有多难 2020-12-02 11:46

Can someone share example codes in Flask on how to access a MySQL DB? There have been documents showing how to connect to sqlite but not on MySQL.

Thank you very muc

8条回答
  •  难免孤独
    2020-12-02 12:15

    Just add pymysql to your app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://username:password@server/db'

    app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://username:password@server/db'
    

    All the best.

提交回复
热议问题