{Denodo}Pythonで接続

 

https://community.denodo.com/kb/en/view/document/How%20to%20connect%20to%20Denodo%20from%20Python%20-%20a%20starter%20for%20Data%20Scientists

pip install sqlalchemy
pip install psycopg2
pip install --upgrade denodo-sqlalchemy

 

## Script name: sqlalchemy-denodo-connection.py

## Importing the main library used to connect to Denodo via sqlalchemy
import sqlalchemy as dbdriver

## Importing the gethostname function from socket to
## put the hostname in the useragent variable
from socket import gethostname

## Connection parameters to the Denodo VDP Server
denodoserver_name = "localhost"

## Default port for ODBC connections
denodoserver_odbc_port = "9996"

denodoserver_database = "db01"

denodoserver_uid = "admin"

denodoserver_pwd = "admin"

## Create the useragent as the concatenation of
## the client hostname and the python library used
client_hostname = gethostname()

useragent = "%s-%s" % (dbdriver.__name__,client_hostname)

## Establishing a connection
cnxn_str = "denodo://%s:%s@%s:%s/%s" %\
       (denodoserver_uid, denodoserver_pwd, denodoserver_name, denodoserver_odbc_port, denodoserver_database)


engine=dbdriver.create_engine(cnxn_str)

## Query to be sent to the Denodo VDP Server
query = "select * from b_tab1"

result_set=engine.execute(query)

## Finally fetch the results. `results` is a list of lists.
## If you don't want to load all the records in memory, you may
## want to use cur.fetchone() or cur.fetchmany()
results = result_set.fetchall()

print(results)