how about:
from sqlalchemy import inspect mapper = inspect(obj) session.expire(obj, [col.key for col in mapper.primary_keys]) make_transient(obj) On 03/17/2016 10:54 AM, milan53064...@gmail.com wrote:
Right now I am taking test run object from local database, then I call expunge on that object (cascade is set to expunge). then I put this object into this python method : def _reset_primary_keys(self, test_run): make_transient(test_run) test_run.ID= None if test_run.OrderNumber: make_transient(test_run.OrderNumber) test_run.OrderNumber.ID= None for equipmentin test_run.TestEquipments: make_transient(equipment) equipment.ID= None for trdin test_run.TestRunToDevs: make_transient(trd) trd.ID= None if trd.TestedDut: make_transient(trd.TestedDut) trd.TestedDut.ID= None for test_stepin trd.TestSteps: make_transient(test_step) test_step.ID= None for test_resultin test_step.TestResults: make_transient(test_result) test_result.ID= None This method reset all primary keys, so I can merge it into master database which will generate new primary keys. Is there a better or easier way how to do it? -- 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 https://groups.google.com/group/sqlalchemy. For more options, visit 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 https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.