Hi, I'm coming to grief trying to create a Mapper on the fly.

At first I tried this

 class Dynamic(object):
                    pass

 Dynamic.mapper = mapper(Dynamic, self.j);

 self.j is a join statement. This now maps all the columns from the
tables in the join statement. Which is fine. Except that in the SQL
query it looks something like  "SELECT table1.id AS id, table2.id AS
id etc etc". So that won't work as the columns don't have alias'.

Next I tried something like this

Dynamic.mapper = mapper(Dynamic,select(fields_to_select,from_obj=
[self.j]),primary_key=[table1.c.id,table2.c.id,table3.c.id])

fields_to_select are the fields I actually need, and they look
something like [table1.c.id,table2.c.id,table3.c.id]. If I want to I
imagine I could individually attach a label() to these and that would
overcome any conflicts with the SQL query.  That's not the problem
though, as it gives me this error

mapper Mapper|Dynamic|{ANON 158092684 anon} could not assemble any
primary key columns for mapped table '{ANON 158092684 anon}'

I've looked around and read the docs, been through the newgroup but
can't seem to figure out where I've gone wrong. Any ideas ?

Cheers

--

You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@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