为了账号安全,请及时绑定邮箱和手机立即绑定

Python:JayDeBeApi 与 Apache Drill 的 JDBC 连接错误错误

Python:JayDeBeApi 与 Apache Drill 的 JDBC 连接错误错误

侃侃无极 2023-10-06 13:46:56
我正在尝试使用库从 python 连接到 Apache Drill jaydebeapi。我已经通过 开启了嵌入模式下的钻取drill-embedded,并且 Web ui 在端口 8047 中正确运行。然后,我尝试通过 python 脚本通过 JDBC 进行连接:import jaydebeapiimport jpypeimport osDRILL_HOME = os.environ["DRILL_HOME"]classpath = DRILL_HOME + "/jars/jdbc-driver/drill-jdbc-all-1.17.0.jar"jpype.startJVM(jpype.getDefaultJVMPath(), "-Djava.class.path=%s" % classpath)conn = jaydebeapi.connect(    'org.apache.drill.jdbc.Driver',    'jdbc:drill:drillbit=localhost:8047')但我收到这个错误SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".SLF4J: Defaulting to no-operation (NOP) logger implementationSLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.Traceback (most recent call last):  File "jaydebe_drill.py", line 10, in <module>    'jdbc:drill:drillbit=localhost:8047'  File "/Users/user/opt/anaconda3/lib/python3.7/site-packages/jaydebeapi/__init__.py", line 412, in connect    jconn = _jdbc_connect(jclassname, url, driver_args, jars, libs)  File "/Users/user/opt/anaconda3/lib/python3.7/site-packages/jaydebeapi/__init__.py", line 230, in _jdbc_connect_jpype    return jpype.java.sql.DriverManager.getConnection(url, *dargs)jpype._jexception.SQLNonTransientConnectionExceptionPyRaisable: java.sql.SQLNonTransientConnectionException: Failure in connecting to Drill: oadd.org.apache.drill.exec.rpc.ChannelClosedException: Channel closed /127.0.0.1:62244 <--> localhost/127.0.0.1:8047.有谁知道如何解决这个问题?
查看完整描述

1 回答

?
沧海一幻觉

TA贡献1824条经验 获得超5个赞

因为drill-embedded没有端口可供选择。下面是完整的查询示例


import jaydebeapi

import jpype

import os

import pandas as pd


DRILL_HOME = os.environ["DRILL_HOME"]

classpath = DRILL_HOME + "/jars/jdbc-driver/drill-jdbc-all-1.17.0.jar"


jpype.startJVM(jpype.getDefaultJVMPath(), "-Djava.class.path=%s" % classpath)


conn = jaydebeapi.connect(

    'org.apache.drill.jdbc.Driver',

    'jdbc:drill:drillbit=localhost'

)


cursor = conn.cursor()


query = """

    SELECT *

    FROM dfs.`/Users/user/data.parquet`

    LIMIT 1

"""


cursor.execute(query)

columns = [c[0] for c in cursor.description]

data = cursor.fetchall()

df = pd.DataFrame(data, columns=columns)


df.head()


查看完整回答
反对 回复 2023-10-06
  • 1 回答
  • 0 关注
  • 81 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信