通过Pysimplegui从Python(3.9.7)与Hive连接
我正在尝试从Python(脚本)连接到Hive,并且连接成功。但是,当我通过创建的GUI传递相同的CONN STR详细信息时,我会发现错误:
gaierror:[Errno 8] NodeName nor servName提供了或不知道哪些导致TransportException:ttransportException(type = 1,message = 1,message =“无法连接到主机,端口,auth_mech,auth_mech,kerb_serv_name,timeout,timeout,timeout,use_ssl”)。<<<<<<)。 /p>
当值直接传递而不是下面的conn str时,上述执行正常:
import pandas as pd
import PySimpleGUI as sg
from impala.dbapi import connect
from impala.util import as_pandas
layout_h = [
[sg.Text('host',size=(10,1)),sg.Input(key='h')],
[sg.Text('port',size=(10,1)),sg.Input(key='p')],
[sg.Text('auth_mechanism',size=(10,1)),sg.Input(key='am')],
[sg.Text('kerberos_service_name',size=(10,1)),sg.Input(key='ksn')],
[sg.Text('timeout',size=(10,1)),sg.Input(key='t')],
[sg.Text('use_ssl(True/False)',size=(10,1)),sg.Input(key='ssl')],
[sg.Button('Test Connection'),sg.Button('Quit')],
[sg.Text('Enter SQL',size=(10,1)),sg.Input(key='sqlquery1')],
[sg.Button('Profile and Save'),sg.Button('Exit')]
]
sg.theme('dark grey 6')
window = sg.Window('Hive',layout_h)
event,values = window.read()
if event == 'Test Connection':
hiv = connect(str(values['h'])+","+values['p']+","+str(values['am'])+","+str(values['ksn'])+","+values['t']+","+values['ssl'])
imp_cursor = hiv.cursor()
imp_cursor.execute(values['sqlquery1'])
AV = as_pandas(imp_cursor)
ps我想我弄乱了conn str(noobie试图自动化他的任务)
I am trying to connect to hive from python (script) and the connection is successful. However when I am passing the same conn str details via a GUI i created, I get the error :
gaierror: [Errno 8] nodename nor servname provided, or not known which leads to TTransportException: TTransportException(type=1, message="Could not connect to host,port,auth_mech,kerb_serv_name,timeout,use_ssl").
The above executes fine when the values are passed directly instead of the conn str below:
import pandas as pd
import PySimpleGUI as sg
from impala.dbapi import connect
from impala.util import as_pandas
layout_h = [
[sg.Text('host',size=(10,1)),sg.Input(key='h')],
[sg.Text('port',size=(10,1)),sg.Input(key='p')],
[sg.Text('auth_mechanism',size=(10,1)),sg.Input(key='am')],
[sg.Text('kerberos_service_name',size=(10,1)),sg.Input(key='ksn')],
[sg.Text('timeout',size=(10,1)),sg.Input(key='t')],
[sg.Text('use_ssl(True/False)',size=(10,1)),sg.Input(key='ssl')],
[sg.Button('Test Connection'),sg.Button('Quit')],
[sg.Text('Enter SQL',size=(10,1)),sg.Input(key='sqlquery1')],
[sg.Button('Profile and Save'),sg.Button('Exit')]
]
sg.theme('dark grey 6')
window = sg.Window('Hive',layout_h)
event,values = window.read()
if event == 'Test Connection':
hiv = connect(str(values['h'])+","+values['p']+","+str(values['am'])+","+str(values['ksn'])+","+values['t']+","+values['ssl'])
imp_cursor = hiv.cursor()
imp_cursor.execute(values['sqlquery1'])
AV = as_pandas(imp_cursor)
P.S. I think I messed up the conn str(noobie trying to automate his tasks)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论