python - SQLAlchemy upsert -


I would like to create tables from two existential tables in different sessions.

For example:

  user {uid, fname, lname} salary {uid, pay} => Firstly I add the user to "newtables", and the salary is zero -> OK  
  n = NewTable (uid = 0, full_name = (user.fname + user.lname) ) Session.add (n) session.commit ()  

... commit, and do something else

and then I "merge" salaries in Newtb, The salary is ok, but the full_name has expired.

  n2 = NewTable (UID = 0, pay = 100) Session.merge (n2) session.commit ()  

Why? How can I increase only some areas? Or just automatically combine this way

After all, I got my solution.

  Inserting from two tables  
  "Select and update" to avoid overwriting a new new object Session.add (doc) for the second table  

:

  session.query (NewTable) .filter (NewTable.uid = = Doc.uid). Update (Doctor)  

Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Messages from .properties file do not display UTF-8 characters -

javascript - amcharts makechart not working -