One of the Python-Web Frameworks - Detailed explanation of some big pits encountered when using Flask!

After this small project, I have a new understanding of the two web frameworks, Django and Flask. Django itself has very complete wheels, and the routines are also very fixed. When newbies come into contact with the Django framework, they will not fall into the big pit of looking for wheels everywhere;

So what big pits will you encounter when using the Flask framework? First of all, Flask is a lightweight web framework. The reason why it is lightweight is that it does not have many wheels. Does that mean these wheels? We need to build it ourselves, not necessarily, but we need to find these wheels. This is precisely the time to exercise your thinking. Before you can find wheels, you must know which wheels you need and what they do. After knowing this, proceed to the next step;

The point is here, what exactly does the wheel mentioned here refer to, and why is it a pit? The documentation and materials of the Flask framework are far less abundant and clear than Django. You may find some materials that seem to be what you need on the Internet. , but it is very likely that the modules and drivers used in it will have large pits with inconsistent versions, and various errors may appear when the wheels are assembled together. At this time, you have to report one error and another error. To solve the problem, check the reason for this error, and check the documentation of the patchwork module. There are many versions of MySQL drivers used here, PyMySQL, MySQLdb, mysql-connector, mysql-connector-python, if If you choose MySQLdb, congratulations you are the python2.x version, if you choose mysql-connector-python, then congratulations again, this only supports python3.4 haha, if you choose PyMySQL, although the program can run, but There will be long strings of red fonts such as various warnings, which are annoying to look at. After the actual measurement, there will be no problem in choosing mysql-connector;

In addition, there are also some pits that use database to add, delete, modify and query statements. Database statements are not as clean as python statements. Some statements need to be added at the end of a semicolon, and some do not need to be added at the end. Sometimes there is even a difference between singular and plural objects. If you are not careful, your statement will have no effect or an error will be reported.

Finally, go directly to the source code and some notes...

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325296373&siteId=291194637