Skip to content

oemof/oemof-db

dev
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
ci
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Overview

PyPI Package latest release Commits since latest release Supported versions PyPI - License

Travis-CI Build Status PyPI Wheel Supported implementations Documentation Status

coveralls status Coverage Status Scrutinizer Status Codacy Code Quality Status CodeClimate Quality Status

Open Energy Modelling Framework - An extension for all database related things

See the documentation for more information!

Installation

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 git@github.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 oemof 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 file 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 arises.

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 dependency of oemof.db, like this:

>>> import keyring
>>> keyring.set_password("database", "username")

where "database" and "username" have the same values as the corresponding options in config.ini.

Development

To run the all tests run:

tox

Note, to combine the coverage data from all the tox environments run:

Windows
set PYTEST_ADDOPTS=--cov-append
tox
Other
PYTEST_ADDOPTS=--cov-append tox

About

Open Energy Modelling Framework - An extension to use the oemof related postgis database (requires database access on oemof-server)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages