How to operate the MySQL database with Flask-sqlalchemy under Python3?

Source: Internet
Author: User
Many online are python2, examples are sqlite, according to others said change Database_uri is unable to operate the MySQL database.
Under Python3 How to use Flask-sqlalchemy to MySQL database operation Ah, seemingly mysqldb does not support Python3
Ask the great God to answer the question ~

Reply content:

Well, it seems that the main problem has been solved, very good. I'm still going to give a little help to the novice who needs it later.

This question is often novice, because most of the tutorials (including the classic "Flask Web Development" book) tell us how to use Flask-sqlalchemy to manipulate SQLite, but in the production environment (online site), we must be using MySQL or other, And most of the tutorials tell us that the way Flask-sqlalchemy uses MySQL is:
mysql://username:password@server/db
Use Pymysql to connect to the database!! Python3 no use, because the Mac comes with or 2.7

You can use the following demo to run under the python2 you say:

Cfrs2005/flask_blog GitHub

Second, pay attention to installing MySQL, PIP installation Mysql-python related support class library
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.