[sqlalchemy] Session with multiple data insert
Hi all, i have the following situation: i have a table (imported_data) with data generated from some wifi terminals and i have other table (using_data) where user can modify / delete the data. Every time i run the program, i need to copy new data of imported_data into using_data. i using this query for get the new data: def newdata(self,src_table,dst_table): lista = config.Sess.query(src_table).outerjoin((dst_table, src_table.ID==dst_table.ID)).filter(dst_table.ID==None).all() return lista So I try to insert all data in the table but always inserts only the last line: for rec in dati: config.Sess.add(rec) config.Sess.commit() Thanks a lot for every suggestions. Ghido -- 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.
[sqlalchemy] Manage Session
Hi all, i have a problem on manage the sessions. I whish to insert 2 object on my database: obj1 = machine() obj2 = action() i want to insert one machine and reuse the id of the machine for insert the action, this part is ok: config.Sess.add(obj1) config.Sess.commit() return config.Sess.refresh(obj1) then i want to insert more action for every machine: obj2.action = 'action1' obj2.freq = 'freq1' config.Sess.add(obj2) obj2.action = 'action2' obj2.freq = 'freq2' config.Sess.add(obj2) obj2.action = 'action3' obj2.freq = 'freq3' config.Sess.add(obj2) config.Sess.commit() But this code doesn't function and the code insert only the last action. Someone can help me? Thanks a lot Ghido --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---