简体   繁体   中英

How to backup & restore data using python for OpenERP?

I have some problem for backup and restore database using python for OpenERP. I would like to backup sale_order table and related tables for this. But... I don't know how to restore that backup file because there have some related keys (foreign key) vice visa..

eg I have backup file for sale_order that related tables like this:

insert into sale_order ....
insert into sale_order_line ...

that time, I have error for sale_order_line because sale_order_line have foreign key for procurement_order's id ... so I changed

insert into sale_order...
insert into procurement_order...
insert into sale_order_line...

but ... I've an error at procurement_order for foreign key for stock_move's id... so I changed again...

insert into sale_order...
insert into stock_move...
insert into procurement_order...
insert into sale_order_line...

but... it's still not OK :( because stock_move have foreign key of sale_order_line'id... I don't know how to do...

That's why... What is the best solution for this backup and restore for that case? If you have any idea, please give me. Thanks.

Without providing schemas for the tables with their foreign keys it's difficult to provide accurate help.

It is possible to generate data that defies a simple batch insert. You can leave a FK null and set it after dependencies are added.

So - you probably want to read up about deferring constraints and disabling foreign keys. Start here for a quick overview and work out from there.

Oh - and are you sure you won't have any problems with overlapping primary keys from this setup?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM