我正在尝试使用python代码中的redshift-fake-driver(https://github.com/opt-tech/redshift-fake-driver)连接到Postgres DB。但是我无法加载驱动程序。
我正在基于rappdw / docker-java-python映像在docker容器中运行python代码
import jpype
import os
import inspect
import jaydebeapi
jar = r'/drivers/redshift-fake-driver_2.12-1.0.10.jar'
args='-Djava.class.path=%s' % jar
jvm_path = jpype.getDefaultJVMPath()
jpype.startJVM(jvm_path, '-ea', args)
conn = jaydebeapi.connect('jp.ne.opt.redshiftfake.postgres.FakePostgresqlDriver',"localhost", "airflow","airflow")
curs = conn.cursor()
当前我遇到此异常:
File "/test.py", line 12, in <module>
"loclahost", "airflow","airflow")
File "/usr/local/lib/python3.6/site-packages/jaydebeapi/__init__.py", line 381, in connect
jconn = _jdbc_connect(jclassname, url, driver_args, jars, libs)
File "/usr/local/lib/python3.6/site-packages/jaydebeapi/__init__.py", line 190, in _jdbc_connect_jpype
jpype.JClass(jclassname)
File "/usr/local/lib/python3.6/site-packages/jpype/_jclass.py", line 73, in JClass
raise _RUNTIMEEXCEPTION.PYEXC("Class %s not found" % name)
jpype._jexception.RuntimeExceptionPyRaisable: java.lang.RuntimeException: Class jp.ne.opt.redshiftfake.postgres.FakePostgresqlDriver not found