Sorry, I’m a little unclear on the web2py manual explanation.
as an example, given app1 and app2
I want to have app2 share the database I have built in app1
So do I change the app2/models/db.py file to show: db = DAL(‘sqlite://storage.sqlite’,migrate=’false’) ?
and include all other myModel.py files in app2/models directory as well?
if the database is in app1/databases/ how does app2 know how to find the correct database file?
This Thread begins to answer the question but I’m still unclear on how to define where the shared database lives.
Note,
DAL(..., migrate=False)just sets the default value ofmigratefor each table — it will not have any effect on the migration status of tables whosedefine_table()calls include their own explicitmigrateargument. If you want to completely disable migrations for an entire db connection (regardless of the individualdefine_table()calls), instead use:Also, to share model definitions between applications, rather than simply copying the model files, you could put the definitions in functions or classes within modules and then import the modules. Another option is to use auto_import:
Note,
auto_importwill import the field names and types, but it will not include DAL-specific attributes, such as validators and defaults, so its usage is somewhat limited.