0 votes
1.1k views
Hello,

I want to replace all electricity processes in my current openLCA database with a new electricity process (that reflects a 100% renewable energy future). The bulk replace method is not feasible in openLCA because I would have to select each electricity process individually and there are several hundred I want to replace.

Is there a way to replace the processes in the database by using the Python console in openLCA? I have tried multiple different approaches in Python but I wasn't able to replace the processes. Nor was I able to replace the exchanges/flows of the old processes with the exchanges/flows of the new process.

Is there a way for such a bulk replacement of processes in Python in openLCA? Or maybe using SQL? Thank you very much for your help in advance.
in openLCA by (160 points)

1 Answer

+1 vote
by (125k points)
edited by
 
Best answer

Do you mean, change the default providers?

Update tbl_exchanges set f_provider = (select id from tbl_processes where ref_id = 'here the ref_id of your process') where f_default_provider in (select id from tbl_processes where name like 'and here your names that you want to replace%')

This of cource can change your database entirely, so make a backup first. You can also ask us for more formal advice, there are also more possibilities (filter the processes where the replacement is done, e.g.). Good luck!

Andreas

- afterthought: this assumes that the existing product is provided by the new process, which you should check too

by (160 points)
Thank you for your help.  I do not only want to change the default providers. I want to replace all of the flows of the old process with the flows (including the default provider and all the new amounts and units etc.) of the new process. Therefore, just replacing the default providers will not suffice.
Moreover, would there be a solution in Python?
by (125k points)
Hm, if you replace everything in a process you can just create a new process? The connection between processes is establishing the LCA model, therefore I was thinking about changing the default providers. You need of course your process, but by setting the default provider to your new process instead of the old process, you change the model. That is not what you want?
by (160 points)
Thank you very much for those additional explanations. The above code snippet you shared did work for me, I just had to change f_provider to f_default_provider.
by (125k points)
ah indeed, thank you; I will edit the post, I wrote the query from memory and that was indeed incorrect. Thanks again!
...