On Mar 22, 2010, at 4:09 AM, marco vaccari wrote:

> Sorry. I speak english in rare occasions.
> 
> No.
> It is not "an insert into a join".
> 
> The result of a join between tables A and B is the VALUES partial set
> for an insert into table C.
> 
> sql = A.join(B).select(A.c.id == an_id, fold_equivalents=True,
> use_labels=False)
> rec = sql.execute().fetchone()
> do_something(rec)
> sql =
> C.insert().values(dict(rec.items())).values(other_column_not_in_AxB=123)
> sql.execute()
> 
> If use_labels is True then rec contains column names not recognised in
> C.

if use_labels=False/fold_equivalents=True makes the names work out perfectly 
then that would be the way to do it.    or you can build the dict() something 
like dict((k.split('_')[1], v) for k, v in row.items()).   We will be improving 
upon "fold_equivalents" in a future release with a similar feature.



> 
> On 19 Mar, 18:13, Michael Bayer <mike...@zzzcomputing.com> wrote:
>> ...
>> can you point me to the SQL syntax for an INSERT into a JOIN  ?
>> ...
> 
> -- 
> 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.
> 

-- 
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