A small python package to execute queries to PDM without having to re-authenticate every time
Project description
PDM Reader
pdmreader
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.
Install
- 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 git+https://github.com/equinor/pdm-reader.git
Usage
See examples/demo.py or try the code below that queries PDM and retrieves data:
import datetime as dt
from pdm_datareader import tools
# 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 = tools.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 = tools.query(sql)
print(df)
Legacy
If you wish to use an older version of this package, this can be done by passing a parameter with the pip-command, e.g.:
pip install git+https://github.com/equinor/pdm-reader.git@v1.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pdm_datareader-2.4.0.tar.gz
.
File metadata
- Download URL: pdm_datareader-2.4.0.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.7 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8df52b9c68c94781ee555868d7327393272a8ccf3df3d570e7c6e11897e9163b |
|
MD5 | 50df62e0383979637fdb5952ae8d51ac |
|
BLAKE2b-256 | 7c2443f9c4375e39417444416b0d6c546b3a4278d825f7dc20e0202b5448b29e |
File details
Details for the file pdm_datareader-2.4.0-py3-none-any.whl
.
File metadata
- Download URL: pdm_datareader-2.4.0-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.7 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 464fc09440bfb45576c26f4ae4cec5cb342561c5bb782e84c2b5017c743c19a6 |
|
MD5 | 825211bceb6a7670af63c89c1be1d8e7 |
|
BLAKE2b-256 | 5ba9e16dc41ce80b779f26108553e469a20e6fa423f291f5a0581fd625ad75eb |