brightway-lca / brightway2-data

Tools for the management of inventory databases and impact assessment methods. Part of the Brightway LCA framework.
https://docs.brightway.dev/
BSD 3-Clause "New" or "Revised" License
8 stars 23 forks source link

Backport #128 to fix #127 on bw2legacy #130

Closed ccomb closed 1 year ago

ccomb commented 1 year ago

Hi, I got the same issue as in #127 but in the bw2legacy branch. So this is a backport of #128 onto bw2legacy.

Traceback (most recent call last):
(...)
  File "/opt/conda/lib/python3.9/site-packages/bw2data/backends/peewee/database.py", line 260, in write
    self._efficient_write_many_data(data)
  File "/opt/conda/lib/python3.9/site-packages/bw2data/backends/peewee/database.py", line 193, in _efficient_write_many_data
    self.delete(keep_params=True, warn=False)
  File "/opt/conda/lib/python3.9/site-packages/bw2data/project.py", line 358, in writable_project
    return wrapped(*args, **kwargs)
  File "/opt/conda/lib/python3.9/site-packages/bw2data/backends/peewee/database.py", line 349, in delete
    sqlite3_lci_db.vacuum()
  File "/opt/conda/lib/python3.9/site-packages/bw2data/sqlite.py", line 57, in vacuum
    self.execute_sql('VACUUM;')
  File "/opt/conda/lib/python3.9/site-packages/bw2data/sqlite.py", line 50, in execute_sql
    return self.db.execute_sql(*args, **kwargs)
  File "/opt/conda/lib/python3.9/site-packages/peewee.py", line 3236, in execute_sql
    cursor.execute(sql, params or ())
  File "/opt/conda/lib/python3.9/site-packages/peewee.py", line 3010, in __exit__
    reraise(new_type, new_type(exc_value, *exc_args), traceback)
  File "/opt/conda/lib/python3.9/site-packages/peewee.py", line 192, in reraise
    raise value.with_traceback(tb)
  File "/opt/conda/lib/python3.9/site-packages/peewee.py", line 3236, in execute_sql
    cursor.execute(sql, params or ())
peewee.OperationalError: cannot VACUUM from within a transaction