pdm-datareader is a python package for querying Production Data Mart tables using SQL. The package handles authentication for end users with user impersonation, but also allows for inserting your own token. It must be run from Equinor managed environments connected to Equinor network.
Pull requests, feature requests and issues are welcomed using the GitHub Project Repository or as a ServiceNow ticket directed to Production Data Mart.
- Ensure that ODBC Driver for SQL Server is installed. Currently supports both v18 and v17.
This driver is bundled with the Microsoft SQL Client package in AccessIT, and should be pre installed on linux environments. Instructions for installing on MacOS can be found here.. - MacOS users must install unixodbc. See https://pypi.org/project/pyodbc/ for current instructions.
- Linux users must apply for Linux compliant device exclusion to get multifactor authentication to work.
- Finally install the latest version of the python package using:
pip install pdm-datareader
See examples/demo.py or try the code below that queries PDM and retrieves data:
import datetime as dt
from pdm_datareader import query
# Example with parameter bindings to avoid SQL injection issues (recommended)
sql = '''
SELECT top(100) *
FROM PDMVW.WELL_PROD_DAY
WHERE COUNTRY = :countrycode
AND PROD_DAY = :startdate
'''
df = query(sql, params={'countrycode': 'NO',
'startdate': dt.datetime(2022, 1, 1)})
print(df)
# Example without parameters (not recommended)
sql = 'SELECT TOP(1) * FROM PDMVW.WELL_PROD_DAY'
df = query(sql)
print(df)