Re: [sqlalchemy] composite type nested

2018-12-13 Thread Tolstov Sergey
To resolve this i try to create proxy object -- 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

Re: [sqlalchemy] composite type nested

2018-12-13 Thread Mike Bayer
maybe clearer class Address(object): def __init__(self, name, value, towndetail): self.name = name self.value = value self.towndetail = towndetail @classmethod def __composite_constructor__(cls, name, value, town_name, town_value): """given name, value, name, value return

Re: [sqlalchemy] composite type nested

2018-12-13 Thread Tolstov Sergey
test_instance.street_address.town_detail.name = 'tataa' after create now work, is it normal? -- 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

Re: [sqlalchemy] composite type nested

2018-12-13 Thread Tolstov Sergey
That's perfect when have not > 3k tables and dont need load compound columns and relationships when called) Without that for create with orm i need ~ 200s with SSD and ~ 60 seconds to load all relationships)) -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper

Re: [sqlalchemy] composite type nested

2018-12-13 Thread Tolstov Sergey
That is my fault, sorry) -- 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

Re: [sqlalchemy] composite type nested

2018-12-13 Thread Mike Bayer
On Thu, Dec 13, 2018 at 8:40 AM Tolstov Sergey wrote: > > Here is my example, how to get arond decorator classmethod (without it not > work, self.__class__ instead of Address not override this function) sure that works too, the docstring now says "any callable" so sure the approach I've

Re: [sqlalchemy] composite type nested

2018-12-13 Thread Tolstov Sergey
Here is my example, how to get arond decorator classmethod (without it not work, self.__class__ instead of Address not override this function) session = sqlalchemy.orm.scoped_session(sqlalchemy.orm.sessionmaker( bind=engine, autoflush=False)) def make_dump(obj): return json.dumps(

Re: [sqlalchemy] composite type nested

2018-12-13 Thread Mike Bayer
On Thu, Dec 13, 2018 at 8:20 AM Tolstov Sergey wrote: > > I cannot undestand, why you use @classmethod? it's an alternate constructor that accepts a, b, c, d as arguments, rather than name, value, towndetail. it's @classmethod because there is no instance of Address when it is called. it's

Re: [sqlalchemy] composite type nested

2018-12-13 Thread Mike Bayer
On Thu, Dec 13, 2018 at 2:08 AM Tolstov Sergey wrote: > > Thanks, Not so bad as expected) Can you add this example to official docs? magic https://docs.sqlalchemy.org/en/latest/orm/composites.html?highlight=composite#nesting-composites > > среда, 12 декабря 2018 г., 20:33:05 UTC+3

Re: [sqlalchemy] composite type nested

2018-12-13 Thread Tolstov Sergey
I cannot undestand, why you use @classmethod? среда, 12 декабря 2018 г., 20:33:05 UTC+3 пользователь Mike Bayer написал: > > composites of composites aren't supported directly so you'd have to > map out all the columns for "street" directly, then define a > constructor that handles the columns:

Re: [sqlalchemy] composite type nested

2018-12-12 Thread Tolstov Sergey
Thanks, Not so bad as expected) Can you add this example to official docs? среда, 12 декабря 2018 г., 20:33:05 UTC+3 пользователь Mike Bayer написал: > > composites of composites aren't supported directly so you'd have to > map out all the columns for "street" directly, then define a >

Re: [sqlalchemy] composite type nested

2018-12-12 Thread Mike Bayer
composites of composites aren't supported directly so you'd have to map out all the columns for "street" directly, then define a constructor that handles the columns: class Address(object): def __init__(self, name, value, towndetail): self.name = name self.value = value

[sqlalchemy] composite type nested

2018-12-10 Thread Tolstov Sergey
Can someone have example of this? Example is class TownDetail(object): def __init__(self, name, value): self.name = name self.value = value def __composite_values__(self): return self.name, self.value def __eq__(self, other): return isinstance(other, self.__class__) and\