Sqlalchemy file organization

Does anyone have any ideas on organizing sqlalchemy based projects? I have many tables and classes with foreign keys and relationships. What does everyone do in terms of separating classes, tables, and cartographers? I am relatively new to the structure, so any help would be appreciated.

Example:

classA.py # table definition and class A definition
classB.py # table definition and class B definition

### model.py
import classA,classB
map(classA.classA,clasSA.table)
map(classB.classB,clasSB.table)

The inclusion of cartographers inside class A and class B works, but creates problems with cross-import when building relationships .. Maybe I'm missing something :)

+3
source share
2 answers

SQLAlchemy's design has two options for avoiding cross-import when defining relationships:

  • backrefthe argument relation()allows you to determine the inverse relationship.
  • ( ). , , .

. .

+1

Pylons, SA.

meta.py

( ). .

, reddit :)

+1

Source: https://habr.com/ru/post/1735377/


All Articles