一个 MySQL 数据库用于许多 web2py 应用程序 [英] One single MySQL database for many web2py applications
问题描述
我的 web2py 框架下有 3 个应用程序.我是否可以为所有这些应用使用一个 MySQL 数据库(通过为表添加前缀),以便用户只需要一次注册即可访问这 3 个应用程序?我的尝试失败了.或者有其他解决方案吗?非常感谢.
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.
推荐答案
如果多个应用程序共享同一个数据库表,除了一个应用程序之外的所有应用程序都必须使用 migrate=False
定义该表以防止迁移尝试.请注意,Auth.define_tables()
还需要一个 migrate
参数,因此要关闭专门针对 Auth
表的迁移,您可以执行以下操作:
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.
这篇关于一个 MySQL 数据库用于许多 web2py 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!