First, preface
In the beginner Flask, in the database connection this part also with each beginner. But with the work of the project to take over more, code to write more, more experience and have their own experience and skills. After a continuous upgrade of the code, a learning experience was organized in connection with the database. I hope we can provide some references on the way to learn Python.
Ii. Primary Stage
1.Mysql expansion Pack
2. Establishing a database connection
3. Turn on the strange upgrade road
In daily development, the most common application scenario for connecting to a database is to query all data and query individual data. Take the example of querying all data scenarios.
Small white version -- in the backend by the table, upload to the front-end rendering
Third, advanced stage
First off--back end eliminates HTML tags
Back end:
Front End:
Second level--make the return values elegant
Third level--make the code more concise
A more efficient way--directly converting the returned nested progenitor to a nested dictionary, commonly used with query ID only, Username scenario
Iv. Summary of Experiences
As a programmer to learn new technical knowledge is necessary, we are our own career, no one can be the pioneer, we are going to experience from the beginning to proficiency to the process of refinement, although the process is very painful, but the joy of harvest is not the envy of others.
Flask connecting to the database to play the blame upgrade tour