Flask uses sqlalchemy to dynamically add the configuration of binds and can switch at will.

problem description

A flask project now has a concept of one project, and all functions are operated under this project. What I want to do now is to create a new database for a new project. Reuse the model that has been written, and all database structures are the same. How can we reuse the code?

the environmental background of the problems and what methods you have tried

ok, now I know that sqlalchemy supports binding multiple databases, you can switch databases through binds, you can connect to mysql and create new databases through pymysql. However, in how to get the newly created database into the binds, the values of binds in the document are all the database addresses we have created.

Mar.30,2021
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e54850-4c9c4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e54850-4c9c4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?