bw2data.backends.utils#
Functions#
|
Check exchange data validity when processing |
|
Convert a Database to another backend. |
|
|
|
|
|
Loads an object's data from the database as a dictionary. |
|
Replace |
|
Transform data from SQLite representation to Python objects. |
Module Contents#
- bw2data.backends.utils.convert_backend(database_name, backend)[source]#
Convert a Database to another backend.
bw2data currently supports the default and json backends.
- Parameters:
database_name (*) – Name of database.
backend (*) – Type of database. backend should be recoginized by DatabaseChooser.
Returns False if the old and new backend are the same. Otherwise returns an instance of the new Database object.
- bw2data.backends.utils.dict_as_activitydataset(ds: Any, add_snowflake_id: bool = False) dict [source]#
- bw2data.backends.utils.get_obj_as_dict(cls: bw2data.signals.SignaledDataset, obj_id: int | None) dict [source]#
Loads an object’s data from the database as a dictionary.
The format used is that of the serialization of revisions (see also the dict_as_* functions above); in particular, an empty dictionary is returned if the ID is None (but not if the object does not exist).
- bw2data.backends.utils.replace_cfs(old_key, new_key)[source]#
Replace
old_key
withnew_key
in characterization factors.Returns list of modified methods.
- bw2data.backends.utils.retupleize_geo_strings(value)[source]#
Transform data from SQLite representation to Python objects.
We are using a SQLite3 cursor, which means that the Peewee data conversion code is not called. So
('foo', 'bar')
is stored as a string, not a tuple. This code tries to do this conversion correctly.TODO: Adapt what Peewee does in this case?