White can understand the combat tutorial taught you the full stack Python Web Development (DAY 7)

Hello everybody, my name is official Qi Jie (qí guān jié), this "white can understand the combat tutorial taught you how Python Web developers full stack" is a zero-based combat tutorial, hands with you to develop a system to take you Learn Python web full stack development, is currently being updated continuously, if you like, then you can focus on the point like bloggers, we will continue to update later.

Bloggers blog article content navigation (live update)
more quality articles Recommended:

White can understand the combat tutorial taught you the full stack Python Web Development (DAY 7)

  Today we come to the actual series of the seventh day, six days before, we have completed the online forum navigation system, login, registration, forum page, post details page, personal page, change passwords, view the published posts , resource area, file upload and download function to achieve, we now have the forum posts can be released, to see details of the post, and reply information, and upload and download resources, the flow of each page of the filter. Let us continue to improve our system this online forum, and today we continue to improve our systems, today we achieve some how we save some plug-ins and database information in our system, and how the project migration.

7.1 version of the plugin file

  Our projects are generally inserted in a lot of different plug-ins, if we want to deploy the project to other machines, we need to know what we installed the plug-in, plug-ins and install them on the machine migration, where we can use pip3 the plug-in version we used in the project to export, you can export to our requirments.txt file, or you can choose;

pip3 freeze >requirements.txt

Here we currently export plug-in information used in this project are:

click==7.1.1
Flask==1.1.1
itsdangerous==1.1.0
Jinja2==2.11.1
MarkupSafe==1.1.1
PyMySQL==0.9.3
Werkzeug==1.0.0

With the increase of our project capabilities, using a plug-in will gradually increase, time-consuming manual installation. After exporting to requirements.txt, we can use pip3 install corresponding version of the plug-in on a machine migration command is installed;

pip3 install -r requirements.txt

So that we can install our development environment and consistent with a plug-in machine migration.

7.2 generating a database table structure data and database migration

  Plug-ins are in front of us to complete the migration, but we did not database would not be able to run our projects, ah, a lot of data that we have in our project database, here we come to the table to generate the structure of our database, first of all we have to create a database , and in the name of our project is consistent, then we can be PyCharm the database of SQL generate tables were generated structure of our database: Here Insert Picture Description
Here Insert Picture Description
  we then directly to the right of the SQL statement to save thousand million, where we can choose to bring their own above save the file as a function, you can create a file to store our SQL statements, here db.sql I use to store and copy the right code into the like in migrate in.

  Now we have established the structure of the database tables completed, here we need to generate an insert statement of our data within the database, the data in our data migration friends. Here is our PyCharm automatically generate Insert statements (strong PyCharm): Here Insert Picture Description
  will we choose the right one folder generation, it will automatically generate an insert statement data after each table we click, we migrate to these machines statement runs just fine.
  Here we have generated in our project to migrate all plug-in version information statement and databases friends. (If you use this Flask-SQLAlchemy conducted using the database, then there are other methods of migration).

Up to this point, we have this series "White can understand the combat tutorial taught you how Python Web developers full stack" to a close, seven Bowen enough so that we get started, Python Web development experience the ease and convenience of the , so that we can develop on their own a lot of interesting sites, then we go down to the following is some optimization of security, there are some RestFul, Redis, CSRF defense so a series of things in here I do not speak up, small partners are interested in continuing the way to go in the Python web can continue learning related to some of the advanced content, the bloggers will be updated from time to time some of the bells and whistles of Sao operation ~ Well, this issue has to end here, there are like small partners can focus the next bloggers, bloggers point to a praise, support of bloggers.

Published 165 original articles · won praise 702 · views 70000 +

Guess you like

Origin blog.csdn.net/qq_43422111/article/details/105288817