According to the Flask web Development book, it is not recommended to use SQLite in a production environment, so when I follow the book and finish the code in the API chapter, I'm going to switch the database to MySQL.
1. Delete these two files now, as this is a file related to the SQLite database previously used
2. Modify the address of the database in the config file in the original project to the MySQL database. You need to install the MySQL database on your native computer now, and you have a user account for: root, Password: root, the database name created is flask. (There is no too much explanation for MySQL here)
For security reasons, you can pass the path
3. You need to install Python MySQL support for your environment at this time
Installing mysql-python-1.2.3 Steps
1> first download in the browser http://sourceforge.net/projects/mysql-python/files/mysql-python/1.2.3/MySQL-python-1.2.3.tar.gz/download
2> Enter this folder input command: Tar zxf mysql-python-1.2.3.tar.gz && CD mysql-python-1.2.3
3>python setup.py Build
4>python setup.py Install
If Environmenterror:mysql_config not found is reported when executing the Python setup.py build, find the location of Mysql_config first, using Find/-name mysql_config , I was in the/usr/local/mysql/bin/mysql_config, and then modify the mysql-python-1.2.3 directory site.cfg file, remove mysql_config=xxx This line of comments, and changed to Mysql_ Config=/usr/local/mysql/bin/mysql_config, whichever is his own machine.
4. Now you can create a script for data migration
Python manage.py DB init
Python manage.py db migrate-m "Initial migration"
Python manage.py DB Upgrade
After executing these commands, these tables should be present in your MySQL database.
Flask Web Development----using MySQL Database