Files in /models directory get loaded automatically so you can create as many files as you wish. I prefer this way: I name all my files with starting underscore, this ensures that the files are loaded before db.py In each 'underscored' file I create definitions for different tables or sets of tables. Than in db.py I just collect everything. E.g.:
_definitions.py file contains: table1_fields = (SQLField('name1', 'string'), SQLField('name2', 'string'), SQLField('name3', 'string')) db.py file contains: db.define_table('headers', *table1_fields ) Of course you can scale it up to any number of files and databases. Foreign keys across databases - I don't know how to implement, I would just use integer fields with proper naming conventions. On Dec 19, 11:28 am, Fran <francisb...@googlemail.com> wrote: > My db.py is becoming very long & unwieldy > > Is there a way of splitting this into separate files? > I can't use the Templating syntax {{include subset.py}} because this > isn't a view. > I can't just do: import subset.py > I can't import as a module because models aren't modules > > I can create a separate database in separate files, but then I can't > seem to cross-reference the 2 together. > If I don't try then it can't find the original 'db': > SQLTable: table does not exist > > If I try to import then that fails too as db.py is not a module > > I quite like the idea of using different databases actually...should > be faster when working in just 1 area & can make the naming system > clearer. > Having each database be a separate file eases maintenance across > multiple developers. > However I do need to be able to have FOREIGN keys in the other > databases (e.g. the 'Person' table will be common across databases) > > Advice welcomed :) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---