Skip to content

Instantly share code, notes, and snippets.

@vicenteg
Created September 27, 2016 21:53
Show Gist options
  • Save vicenteg/248ac5f59d6eebf4c895631b3c95ae3d to your computer and use it in GitHub Desktop.
Save vicenteg/248ac5f59d6eebf4c895631b3c95ae3d to your computer and use it in GitHub Desktop.

Install unixODBC-devel

yum -y install unixODBC-devel

Install python-virtualenv

yum -y install python-virtualenv

Create a virtualenv in which to install pyodbc:

virtualenv pyodbc

Source the virtualenv, then install pyodbc:

source pyodbc/bin/activate
pip install pyodbc

Now run odbctest.py (download from this gist):

./odbctest.py

You should see something like this:

(pyodbc)[centos@ip-172-16-2-50 ~]$ ./odbctest.py
[('1.6.0', '95b68fcb58bc033c9cd99961f5768ceb1bfae9a1', 'DRILL-4715: Fix java compilation error in run-time generated code when query has large number of expressions.', '24.06.2016 @ 18:21:05 UTC', 'Unknown', '24.06.2016 @ 21:13:15 UTC')]
#!/usr/bin/env python
import pyodbc
import re
# make sure the Drill ODBC driver is installed
MY_DSN = """
Driver = /opt/mapr/drillodbc/lib/64/libmaprdrillodbc64.so
ConnectionType = Zookeeper
ZKQuorum = 172.16.2.50:5181
ZKClusterID = vgonzalez_zeppelin-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='mypassword', autocommit=True)
cursor = conn.cursor()
cursor.execute("SELECT * FROM sys.version")
print cursor.fetchall()
(pyodbc)[centos@ip-172-16-2-50 ~]$ ./odbctest.py
[('1.6.0', '95b68fcb58bc033c9cd99961f5768ceb1bfae9a1', 'DRILL-4715: Fix java compilation error in run-time generated code when query has large number of expressions.', '24.06.2016 @ 18:21:05 UTC', 'Unknown', '24.06.2016 @ 21:13:15 UTC')]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment