2

I'm trying to extract some tables from a database using Python script I created...

import jaydebeapi as jdbc
import pandas.io.sql as psql
import pandas
import getpass
import yaml
p = yaml.load(file("/Users/glassjawed/.TD"))
# Contains password
c = jdbc.connect('com.teradata.jdbc.TeraDriver'
,['jdbc:teradata://******.***.***.com','glassjawed',p]
,['~/terajdbc4.jar','~/tdgssconfig.jar'])

# read in the table we want
df = psql.read_sql('SELECT TOP 10 user_id FROM store_users',c)
print(pandas.DataFrame.head(df))
print(type(df))

but I'm running into the following error.

  File "EPNconnect.py", line 11, in <module>
    ,['~/terajdbc4.jar','~/tdgssconfig.jar'])
  File "/usr/lib/python2.7/dist-packages/jaydebeapi/__init__.py", line 359, in connect
    jconn = _jdbc_connect(jclassname, jars, libs, *driver_args)
  File "/usr/lib/python2.7/dist-packages/jaydebeapi/__init__.py", line 182, in _jdbc_connect_jpype
    jpype.JClass(jclassname)
  File "/usr/lib/python2.7/dist-packages/JPype1-0.6.1-py2.7-linux-x86_64.egg/jpype/_jclass.py", line 55, in JClass
    raise _RUNTIMEEXCEPTION.PYEXC("Class %s not found" % name)
jpype._jexception.RuntimeExceptionPyRaisable: java.lang.RuntimeException: Class com.teradata.jdbc.TeraDriver not found

I installed the latest jar files and I'm still getting this error. I don't know how to work around this. Help?

Kashif
  • 3,063
  • 6
  • 29
  • 45
  • I starred out the ******.***.***.com because I don't want to reveal my place of employment. – Kashif Oct 21 '15 at 16:12
  • Are you certain you have both terajdbc4.jar and tdgssconfig.jar? I see you have them listed in your `.connect` call, but the error suggests that perhaps one of them isn't present in your user's home directory. Furthermore, because you are using the `~` home directory alias, make sure that you are running this script as the user that has the two jar files in their home directory. – JNevill Oct 22 '15 at 17:49
  • Please see my answer @Glassjawed. Make sure you have included all the dependencies. – phoenix Oct 29 '15 at 10:33

2 Answers2

1

When using JayDeBeApi I made some sad experience when using ~ in my filenames. Try the absolut path instead, eg:

    c = jdbc.connect('com.teradata.jdbc.TeraDriver', ['jdbc:teradata://******.***.***.com','glassjawed',p]
,['/Users/myUserID/terajdbc4.jar', '/Users/myUserID/tdgssconfig.jar'])

Beside this I'm a big fan of using teradata package (and ODBC) instead of JayDeBeApi (and JDBC) when using Python.

hhoeck
  • 361
  • 2
  • 3
0

Kindly refer to this post

You need to get Teradata JDBC drivers and give correct path of respective jars. It should work.

Mithilesh Kumar
  • 256
  • 1
  • 3
  • 18