Hi,

maybe I've overlooked something very trivial, but how can I populate a
mapped class from a RowProxy?

Here's a simple example of what I'd like to do (using TurboGears):

class Foo(object):
  pass

database.mapper(Foo, database.metadata.tables["footable"])

Now I have a rather complex SQL that I would like to execute directly
instead of using object queries:

sql = "select * from footable where something_really_complex_happens"
for rp in database.session.execute(sql):
  f = Foo()
  for key, value in rp.iteritems():
    setattr(f, key, value)

The problem is that when I try to save the created object, it tries to
do an INSERT instead of an UPDATE and that AppenderQueries defined in
the mapping don't work as they try to build a JOIN condition with None
instead of the primary key.

There must be something wrong with this approach :) Any tipps how to
solve this?

Andi

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to