On 2015-03-13 13:58 Jonathan Vanasco jonat...@findmeon.com 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.
Thats a mixin class that can be added onto any object inheriting from
declared_base. You only need one of the `columns_as_dict` options. I
showed 3 variations: one that gives all columns, one that lets you specify
which columns to include, and another that shows which columns to exclude.
data-entry instead of an clean empty
new-data-dialog. In the latter the user need to type in all data again
but e.g. 80% of it is the same then yesterday. Understand?
What do you think about this solution:
https://stackoverflow.com/questions/29039635/how-to-duplicate-an-sqlalchemy-mapped-object
care about and
which
ones you don’t.
What do you think about this solution:
https://stackoverflow.com/questions/29039635/how-to-duplicate-an-sqlalchemy-mapped-object-the-correct-way
if it works for you, then it’s great. It’s not a generalized solution for
the whole world, though. It doesn’t
Use a mixin on the classes to create a dict of the column values. Then
create a new object with that dict.
You can customize the mixin to include or exclude columns as you wish.
I use this approach for revision tracking.
Class Duplicable(object)
@property
def columns_as_dict(self):
moon...@posteo.org wrote:
On 2015-03-08 11:17 Michael Bayer mike...@zzzcomputing.com wrote:
there’s no particular “SQLAlchemy way” to do this,
What is about
make_transient()
?
I don't understand this function 100%tly.
it changes the state of an object from persistent to
moon...@posteo.org wrote:
On 2015-03-08 11:17 Michael Bayer mike...@zzzcomputing.com 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.
which is why, “copy
On 2015-03-08 11:17 Michael Bayer mike...@zzzcomputing.com 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
On 2015-03-08 11:17 Michael Bayer mike...@zzzcomputing.com 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
moon...@posteo.org wrote:
On 2015-03-07 03:17 moon...@posteo.org 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?
there’s no particular “SQLAlchemy way” to do
On 2015-03-07 03:17 moon...@posteo.org 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
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
12 matches
Mail list logo