Connecting to QDS Using SQLAlchemy-Qubole PackageΒΆ

Here is an example to connect to QDS and submit a Presto query:

# Qubole presto
from sqlalchemy import create_engine
engine = create_engine('qubole+presto://presto/presto_cluster?endpoint=https://api.qubole.com;password=********;catalog_name=hive')

with engine.connect() as con:
rs = con.execute('SHOW TABLES')
for row in rs:
print(row)

In the create_engine method, enter an SQLAlchemy URI to connect to QDS Presto or Hive. Below are the different Qubole dialects supported by SQLAlchemy:

  • Presto Dialect: qubole+presto://presto/presto_cluster?endpoint=https://api.qubole.com;password=<API-TOKEN>;catalog_name=hive (QDS Dialect points to Presto by default.)
  • Hive Dialect: qubole+hive://hive/hadoop2?endpoint=https://api.qubole.com;password=<API-TOKEN>

You could add additional JDBC parameters and separate them with a semicolon(;). For more information on JDBC connection properties, see Setting the JDBC Connection String.