问题
I have 3 apps under my web2py framework. Can I use one single MySQL database for all of them (by prefixing tables) so users just need only one single registration to access those 3 apps? I fail on my attempts. Or any other solutions? Thanks so much.
回答1:
If multiple apps share the same database table, all but one of the apps must define that table with migrate=False
to prevent migration attempts. Note, Auth.define_tables()
also takes a migrate
argument, so to turn off migrations specifically for the Auth
tables, you can do:
auth.define_tables(migrate=False)
You can also turn off migrations for an entire database connection within an application with:
db = DAL(..., migrate_enabled=False)
See here for more about inter-app cooperation.
来源:https://stackoverflow.com/questions/8033307/one-single-mysql-database-for-many-web2py-applications