Created
March 19, 2018 19:22
-
-
Save anilpai/545fe3017dcb159ed16b48ef65fbd173 to your computer and use it in GitHub Desktop.
Connecting to JDBC databases using python
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 jaydebeapi | |
username = '' | |
password = '' | |
conn = jaydebeapi.connect('com.qubole.jdbc.jdbc41.core.QDriver', | |
'jdbc:qubole://hive/default/db_name?endpoint=https://us.qubole.com', | |
['', password]) | |
if conn: | |
print('Connection with Qubole established.') | |
cursor = conn.cursor() | |
query = 'select count(*) cnt from db_name.app' | |
result = cursor.execute(query) | |
data = cursor.fetchone()[0] | |
print(data) | |
cursor.close() | |
conn.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment