denodoclient

Thin high level client to use when consuming data through the Denodo proprietory ODBC driver.


Keywords
denodoclient
License
MIT
Install
pip install denodoclient==1.0.1

Documentation

Denodo Client

PyPI license PyPI version shields.io PyPI pyversions PyPI download month Unit tests Publish to pypi

Thin high level client to use when consuming data through the Denodo proprietory ODBC driver.

This project is not in any way associated with Denodo.

  • Free software: MIT license

Features

  • ODBC cursor low-level access to Denodo with sensible default connection string
  • High-level client using Pandas to fetch results to a dataframe, all in one go or chunkwise
  • Simple query templating functionality

How to use

Requires python 3.8 or higher.

pip install denodoclient pandas

Query to dataframe

from denodoclient.dataframes import DenodoDataFrameClient
from denodoclient import VqlQuery
from pathlib import Path

client = DenodoDataFrameClient("database_name")
vqlquery = VqlQuery(Path("examples/template.sql"))
df = client.query(vqlquery).to_dataframe()

Using pyodbc cursor without pandas

from denodoclient import DenodoClient
from denodoclient import VqlQuery
from pathlib import Path
client = DenodoClient("database_name")
vqlquery = VqlQuery(Path("examples/template.sql"))
cursor = client.query(vqlquery).cursor
# Do whatever you want with the pyodbc cursor

Changing the default connection string

Default server is denodo and default ODBC driver name is DenodoODBC Unicode(x64). You can change this by passing parameters in as follows.

from denodoclient import DenodoClient
from denodoclient import VqlQuery
from pathlib import Path
client = DenodoClient("database_name", DRIVER="my_denodo_driver", SERVER="denodo-uat")

For a list of options, have a look at DenodoClient.OPTIONS.

print(DenodoClient.OPTIONS)

Dynamically change query parameters

You can just set parameters on the query object, or in the constructor.

SELECT * FROM table WHERE name = "{foo}";
from denodoclient import VqlQuery
from pathlib import Path
vqlquery = VqlQuery(Path("examples/template.sql"), foo="John")
vqlquery.foo = "Mark"

# You can set any variable you want
vqlquery.baz = "Foobaz!"

# See a list of the currently set variables
print(vqlquery.tokens)

# See the string representation of the query
print(str(vqlquery))

Caveats

Please be aware that the templating functionality in this package is vulnerable to SQL-injection attacks. Use with caution.

Credits

This package was created at DFDS.

Contributors

Martin Morset

Contributing

Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.

If you find bugs or have a feature request, please file an issue.

If you are reporting a bug, please include:

  • Your operating system name and version.
  • Any details about your local setup that might be helpful in troubleshooting.
  • Detailed steps to reproduce the bug.