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 21 forks source link

removal of bw2data.project.create_database? #58

Closed aleksandra-kim closed 6 years ago

aleksandra-kim commented 6 years ago

Original report by Anonymous.


I was using the create_database function from bw2data.projects and my IDE made me update bw2data today, but now my program doesnt start anymore, as it cannot import that function. Was it removed? With what update was it removed? I tried to find that out so I could revert back to that version, or find out where that function might have been moved or renamed.

Here is my output:

#!python

File "/Users/USR/PycharmProjects/activity-browser/activity_browser/app/controller.py", line 8, in <module>
    from bw2data.project import ProjectDataset, create_database
ImportError: cannot import name 'create_database'
aleksandra-kim commented 6 years ago

Original comment by Chris Mutel (Bitbucket: cmutel, GitHub: cmutel).


This change was made in version 3.1, which adapted to changes in peewee 3.0. However, the broken import comes from the activity-browser package, which needs to be updated as well; exact procedure will depend on your installation choices. You could also remove it for the time being if that is easier.

The function create_database can simply be skipped, because peewee 3.0 simplified the way SQLite databases are handled. To create a new database, just instantiate and register it:

#!python

    obj = Database("some name")
    obj.register()

register also takes keyword arguments for metadata.