Skip to content

Instantly share code, notes, and snippets.

@cjmatta
Created July 20, 2015 16:27
Show Gist options
  • Save cjmatta/d96a83d979773e640acd to your computer and use it in GitHub Desktop.
Save cjmatta/d96a83d979773e640acd to your computer and use it in GitHub Desktop.
Drill with Python ODBC
import pyodbc
import re
# make sure the Drill ODBC driver is installed
# this is for Mac
MY_DSN = """
Driver = /opt/mapr/drillodbc/lib/universal/libmaprdrillodbc.dylib
ConnectionType = Zookeeper
ZKQuorum = node10:5181,node11:5181,node12:5181
ZKClusterID = se1-drillbits
Catalog = DRILL
AuthenticationType = Basic Authentication
AdvancedProperties = CastAnyToVarchar=true
HandshakeTimeout = 5
QueryTimeout = 180
TimestampTZDisplayTimezone = utc
ExcludedSchemas = sys,INFORMATION_SCHEMA
NumberOfPrefetchBuffers = 5
"""
# Build DSN
MY_DSN = ";".join(
[re.sub(r'(\t+|\s+)=\s+', '=', i) for i in MY_DSN.split('\n') if i != '']
)
conn = pyodbc.connect(MY_DSN, UID='username', PWD='password', autocommit=True)
cursor = conn.cursor()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment