The problem of flask sqlalchemy connecting to multiple databases

flask connects two databases, and the secondary database is bound with bind key, so there is no problem with the use of most tables. However, if there is a table with the same name and the structure of the table is different, the result will always be an error. When you report an error in query, you can"t find the field. It feels like the structure of the main database is used to check the data of the secondary database, resulting in the field unknown. There is no good solution. One way is to instantiate a sqlalchemy object and use the new object as the base class for the model of the subdatabase. Is there any good solution?

Apr.09,2021

you can distinguish tables with the same name by specifying _ _ tablename__ .

class A1(db.Model):
    __tablename__='a'
    ...
    
class A2(db.Model):
    __tablename__='a'
    ...
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-1b3dfb6-4da75.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-1b3dfb6-4da75.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?