Re: [sqlalchemy] duplicate an object

2015-03-14 Thread moonkid
On 2015-03-13 13:58 Jonathan Vanasco wrote: > Use a mixin on the classes to create a dict of the column values. > Then create a new object with that dict. > [..] Looks complex. My solution has only one function, work for nearly all simple declarative_base() derived classes. When I understand yo

Re: [sqlalchemy] duplicate an object

2015-03-14 Thread moonkid
On 2015-03-13 17:24 Michael Bayer wrote: > if it works for you, then it’s great. It’s not a generalized solution > for the whole world, though. It doesn’t take into account columns > that are part of unique Index objects or columns that are mentioned > in standalone UniqueConstraint objects. Than

Re: [sqlalchemy] duplicate an object

2015-03-13 Thread moonkid
On 2015-03-12 09:53 Michael Bayer wrote: > which is why, “copy an object” is not an out of the box thing. Because > nobody really wants a full “copy”, it’s something custom. As I described I don't want a "full copy". I only want to copy the "real data" handled by the user. All organizing/protocol

Re: [sqlalchemy] duplicate an object

2015-03-11 Thread moonkid
On 2015-03-08 11:17 Michael Bayer wrote: > new_obj = MyClass() > for attr in mapper.attrs: > setattr(new_obj, attr.key, getattr(old_obj, attr.key)) This would copy everything including primary keys and unique members. I have hard problems with the SQLA-docu. I know that 'attr' is from type '

Re: [sqlalchemy] duplicate an object

2015-03-11 Thread moonkid
On 2015-03-08 11:17 Michael Bayer wrote: > there’s no particular “SQLAlchemy way” to do this, What is about make_transient() ? I don't understand this function 100%tly. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from

Re: [sqlalchemy] duplicate an object

2015-03-08 Thread moonkid
On 2015-03-07 03:17 wrote: > Is there a in-build-function to duplicate the instance of a data > object (except the primary key)? Isn't there a way for this? Does the sqla-devs reading this list? -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. T

[sqlalchemy] duplicate an object

2015-03-06 Thread moonkid
I am using SQLAlchemy with PostgreSQL and Python3. Is there a in-build-function to duplicate the instance of a data object (except the primary key)? Somebody suggested me this self-build function but I would like to use the SQLAlchemy-way if there is one. >From