pyprediktormapclient.dwh package

Subpackages

Submodules

pyprediktormapclient.dwh.db module

class pyprediktormapclient.dwh.db.Db(url: str, database: str, username: str, password: str, driver_index: int = -1)[source]

Bases: Dwh

This class is not used in the current version of pyPrediktorMapClient.

It was replaced by Dwh from pyPrediktorUtilities. It is left here for backwards compatibility only.

pyprediktormapclient.dwh.dwh module

class pyprediktormapclient.dwh.dwh.DWH(url: str, database: str, username: str, password: str, driver_index: int = -1)[source]

Bases: Dwh, IDWH

Helper functions to access a PowerView Data Warehouse or other SQL databases. This class is a wrapper around pyodbc and you can use all pyodbc methods as well as the provided methods. Look at the pyodbc documentation and use the cursor attribute to access the pyodbc cursor.

Parameters:
  • url (str) – The URL of the sql server

  • database (str) – The name of the database

  • username (str) – The username

  • password (str) – The password

connection

The connection object

Type:

pyodbc.Connection

cursor

The cursor object

Type:

pyodbc.Cursor

Examples - of low level usage:
>>> from pyprediktormapclient.dwh import DWH
>>>
>>> dwh = DWH("localhost", "mydatabase", "myusername", "mypassword")
>>>
>>> dwh.fetch("SELECT * FROM mytable")
>>>
>>> dwh.execute("INSERT INTO mytable VALUES (1, 'test')")
Examples - of high level usage:
>>> from pyprediktormapclient.dwh import DWH
>>>
>>> dwh = DWH("localhost", "mydatabase", "myusername", "mypassword")
>>>
>>> database_version = dwh.version()
>>>
>>> enercast_plants = dwh.enercast.get_plants_to_update()
version() Dict[source]

Get the DWH version.

Returns:

A dictionary with the following keys (or similar): DWHVersion, UpdateDate, ImplementedDate, Comment, MajorVersionNo, MinorVersionNo, InterimVersionNo

Return type:

Dict

pyprediktormapclient.dwh.idwh module

class pyprediktormapclient.dwh.idwh.IDWH[source]

Bases: ABC

abstract execute(query: str, *args, **kwargs) List[source]
abstract fetch(query: str, to_dataframe: bool = False) List[source]
abstract version() Dict[source]

Module contents