Created
July 20, 2015 16:27
-
-
Save cjmatta/d96a83d979773e640acd to your computer and use it in GitHub Desktop.
Drill with Python ODBC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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