Below is my code to connect to Teradata through a JDBC connection using Jaydebeapi. When i run the query using the razorsql GUI, it takes only 15 seconds. When i run it through the code below, it took over 20 minutes just to run query1.
Is there anything wrong with the Jaydebeapi or can i make it faster by optimizing my query/using Jpype?
#-*- coding: utf-8 -*-
import jaydebeapi
import jpype
import pandas as pd
import numpy as np
import collections
query_dict=collections.OrderedDict()
connection = jaydebeapi.connect('com.teradata.jdbc.TeraDriver', ['my_db_name','my_username','my_password'], ['/Applications/drivers/tdgssconfig.jar','/Applications/drivers/terajdbc4.jar'],)
cur = connection.cursor()
query_name_list=['query1','query2']
query1= """select ......"""
query2= """ select ....."""
for i in query_list:
query_dict[i]=locals()[i]
print query_dict.keys()
for index in range(len(query_list)):
tera_query=query_dict.values()[index]
cur.execute(tera_query)
print "executing ... "
result=cur.fetchall()
print "fetching results ... "