I generally write the SqlAlchemy models as a separate package, then import 
that into my MVC/etc patterned app.

In terms of the SqlAlchemy logic, some of that I keep in the models 
package, others are in the core app.

This allows other apps and utilities to be built off the SqlAlchemy models 
and be imported cleanly.  This way cron jobs, migrations, admin tools, etc 
etc can just leverage a shared central model, which is fairly lean.  So my 
general advice is to approach things with two packages, one for [M] and the 
other for [VC]



On Sunday, March 3, 2019 at 6:19:29 PM UTC-5, Rich wrote:
>
> Starting my first SA project (have one more planned after this one's 
> working) and appreciate advice on organizing project files. I understand 
> the 
> MVC pattern and am trying to apply it with subdirectories of model/, 
> view/, 
> and controller/ yet I'm unsure where to place SQLAlchemy. 
>
> This is the overall structure: the backend is a postgresql database, SA 
> will 
> access it via psycopg2 (the engine should be properly configured for 
> this), 
> and the GUI is being written using tkinter. 
>
> Now, ../model/model.py has the classes that represent the postgres table; 
> ../views/ contains four files: data_entry_dialogs.py, ttkcalendar.py, 
> commonDlgs.py, and data_entry_validators.py; and ../controller/ is empty. 
>
> One of the classes in data_entry_dialogs.py has two ttk.Combobox widgets 
> whose values are in two classes in models.py. I assume that a properly 
> structured SA statement (not yet written or tested) can select the rows 
> from 
> the two tables, store them in a list, and that list passed to the 
> ttk.Comboboxes for their input_arg values. I'll work on an appropriate 
> statement RSN, but now want to learn whether to put all SA code in 
> models.py, in the model/ directory, or the controller/ directory. 
>
> If this is in the ORM tutorial I've missed seeing it so pointers to docs 
> that address these two issues are very welcome. 
>
> TIA, 
>
> Rich 
>
>

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to