On Thu, Sep 28, 2017 at 4:29 AM, Tolstov Sergey <whistler...@gmail.com> wrote:
> i haven't found solution for this. Problem in very load compile (40 sec).
>  I have a :
>  - more then 1200 classes
> - 300 enums
> - and some custom primitive classes for working
> - 7 levels of polymorphic inherits
> - some itself relationship, may one-to-many and many-to-many in one class to
> itself
> - parents and childs may have somenamed relationship to one table
>
> I undestand, that's big project, but in develop i need load ~100 classes. Do
> the product exists that can do it or i need to create custom class map and
> custom factory?

hmmmm by "compile" are you referring to just when you "import" the
Python files and the mappers go into the "compile()" phase?   is it
possible you could organize your imports such that not all 1200
classes are imported every time?     to deal with the issue of
linkages between classes, you can have dependent classes add their
dependencies to the classes they depend on only when they are
imported.   Even something like a foreign key column can work this
way:

#  myapp/module_a.py

class SomeImportantClass(Base):
   __tablename__ = "important"

  # ...


# myapp/module_b.py

from myapp import module_a

class SomeNotImportantClass(Base):
   __tablename__ = 'not_important'


module_a.SomeImportantClass.not_important_fk =
Column('not_important_fk', ForeignKey('not_important.id'))

as long as you only import module_a and not module_b, you only get
SomeImportantClass set up and not SomeNotImportantClass.   Assuming
you don't need to refer to the "SomeImportantClass.not_important_fk"
column, it doesn't need to be there, even for inserts where it would
get inserted with NULL.

If you have 1200 classes I'd try to work the modules into clusters
that have a uni-directional dependency chain:


       [super important modules]
                       ^
                       |
     [usually needed modules]      <------ [ dont need these much]
                      ^
                      |
         [ dont need these]







>
>
> --
> 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.

-- 
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