Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><em>As per the requests to my initial question, I've taken my third edit and made it my answer. As I'm not sure of the proper protocols, I've left the third edit in place above. If you've already read EDIT3, then you've read what I have as an answer.</em></p> <p>I've managed to spend a little more time on this. I've set up the project in the following way:</p> <pre><code>Databases __init__.py databases.py settings.py DB1 __init__.py models.py ... DB3 __init__.py models.py </code></pre> <p>At present, I have a tupple of databases that are 'installed' in the settings.py file. Each entry is would like like <code>INSTALLED_DATABASES = ('DB1', ..., 'DB3')</code>. As I complete more models, and they get added to the list of tupples. This allows me to add or remove content as I go.</p> <p>I have the engine and sessios setup inside the models.py file, and have the <strong>init.py</strong> file for each database setup to <code>from models import *</code>.</p> <p>In the databases.py file I have the following </p> <pre><code>class Databases(object): def __init__(self): for database in INSTALLED_DATABASES: setattr(self, database, __import__(database)) </code></pre> <p>I can now use these via:</p> <pre><code>from databases import Databases db = Databases() for qr in db.DB1.query(db.DB1.User): print qr.userid, qr.username </code></pre> <p>SQLAlchemy is allowing me to manually specify column names when defining the models, which is a huge bonus to the standardization I wanted.</p> <p>I've got a lot of work ahead of me still. I would like to create objects that force model validation (ie, is a field present? does a non-present field have a default value? etc.) and better incorporate how this works with my IDE (it kind of doesn't at present). But I'm off to the right track. I figured I'd update this for anyone who might by chance be wondering how to do the same thing I was.</p> <p>Sorry this has become so long!</p> <p>Cheers!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload