Open Energy Modelling Framework - An extension for all database related things
See the documentation for more information!
pip install oemof.db
You can also install the in-development version with:pip install https://github.com/oemof/oemof.db/archive/master.zip
Unfortunately installing the PyPi package doesn't work until #28 is fixed. Instead, you have to install via:
pip install -e git://github.com/oemof/oemof.db.git@master#egg=oemof.db
Note that you have to have git installed for this to work.
If you want to have the developer version clone the repository by
git clone email@example.com:oemof/oemof.db.git
and you can install it using pip3 with the -e flag.
sudo pip3 install -e <path/to/the/oemof.db/repository/root/directory>
Keep virtualenvs in mind!
Configuration and usage
As the purpose of this package is to facilitate usage of the
database, it needs to know how to connect to this database. Being part of
oemof, as fallback
oemof.db always looks for this configuration in the
config.ini in a directory called
.oemof in your home directory.
A particular config-file can either specified and accessed via
from oemof.db import cfg # only load config file cfg.load_config(config_file=<you-config-file>) # access config parameters cfg.get(<section>, <parameter>)
If you're interested in establishing a database connection and specify config file connection parameters are stored in use
from oemof.db import cfg # establish database connection with specified section and config_file db.connection(section=<section>, config_file=<you-config-file>)
To configure database access this file has to have at least one dedicated section containing the necessary options, like this:
[postGIS] username = username under which to connect to the database database = name of the database from which to read host = host to connect to port = port to connect to pw = password used to connect with the given username (OPTIONAL)
The section is assumed to be named
postGIS by default, but you can name it
differently and have multiple sections for different databases if the need
The password is optional. If you don't want to store the password in the
config.ini, you may store it using the keyring package, which is a
oemof.db, like this:
>>> import keyring >>> keyring.set_password("database", "username")
"username" have the same values as the
corresponding options in
To run the all tests run:
Note, to combine the coverage data from all the tox environments run:
set PYTEST_ADDOPTS=--cov-append tox