20 Ekim 2010 10:38 tarihinde Aydın ŞEN <[email protected]> yazdı:
> *
> *
> *myDict = {"title": "newTitle", "content": "newContent"}*
> *
> *
> myDict values are arbitrary so i want to update MyTable with only keys and
> values in myDict (not write one by one table fields). What is the elegant
> way to do this?
>
>
>
This is my way to achieve first issues:
#myDict has some arbitrary update values as a dict
obj = session.query(MyTable).filter(MyTable.id == myDict.id).one()
for k in MyTable.__table__.columns.keys():
if myDict.has_key(k):
setattr(obj, k, myDict[k])
session.add(obj)
session.commit()
I wonder that this is the elegant way to do this.
Second one is still a problem for me. How can i update relations when i
update related object?
--
Aydın Şen
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.