idiomatically this would be: tube1 = session.query(Phototubes).filter(<get the first object>).one() tube2 = Phototubes(gain = new_gain, transactiondate = tube1.transactiondate, serialnumber=tube1.serialnumber) session.add(tube2) session.commit()
That’s a SELECT then an INSERT. In the event that you’re looking for something more exotic than that (like, an INSERT that embeds the SELECT) let us know. > On Nov 26, 2014, at 5:37 AM, joecav...@hotmail.it wrote: > > Hello, > > i'm new on sqlalchemy and i have a problem. > I want to update the entry in a column of a table of a row using the info of > a new row. For example, i could have measured a value in a certain date > > class Phototubes(Base): > __tablename__ = 'MaPMTs' > SerialNumber = Column(String, primary_key=True) > Gain = Column(Float) > TransactionDate = Column( > DateTime, > default=func.now()) > ) > > Now, I would add a column "End_Of_Validity = Column(DateTime)" so that if I > measure a new value of the Gain of the same phototube (so I add a new row > with the same SerialNumber but different value of Gain) I can update the > previous entry of column End_Of_Validity with this TransactionDate (otherwise > empty). How can I do this? > Many Thanks, > Giovanni > > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to sqlalchemy+unsubscr...@googlegroups.com > <mailto:sqlalchemy+unsubscr...@googlegroups.com>. > To post to this group, send email to sqlalchemy@googlegroups.com > <mailto:sqlalchemy@googlegroups.com>. > Visit this group at http://groups.google.com/group/sqlalchemy > <http://groups.google.com/group/sqlalchemy>. > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.