Python连接到已打开加密的EXASOL

时间:2018-04-05 13:27:17

标签: python encryption pyodbc exasolution

我正在尝试通过python连接到加密的exasol数据库。它在未加密时连接没有问题。

EXASOL.connect似乎是基于pyodbc,是否有人在使用开启加密的pyodbc时取得了成功?

我尝试将 ENCRYPTION = Y 作为字符串参数传递,基于manual (page 343)但没有成功。

  

ENCRYPTION打开自动加密功能。有效值为" Y"和" N" (默认   是" N")。

似乎忽略了它。 保持爆炸 - 操作错误:数据库错误[08004]连接异常 - 客户端连接必须加密。

database_table = "SCHEMA_NAME.MY_TABLE"
conn = EXASOL.connect('ws://192.168.56.101:8563', 
                      'UID=sys', 
                      'PWD=pwd', 
                      'ENCRYPTION=Y', 
                      )

sql = "SELECT * FROM %s LIMIT 1000;" % database_table
df_sql = pd.read_sql(sql, conn)
/home/ec2-user/anaconda3/envs/mxnet_p27/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in run_cell_magic(self, magic_name, line, cell)
   2115             magic_arg_s = self.var_expand(line, stack_depth)
   2116             with self.builtin_trap:
-> 2117                 result = fn(magic_arg_s, cell)
   2118             return result
   2119 

<decorator-gen-60> in time(self, line, cell, local_ns)

/home/ec2-user/anaconda3/envs/mxnet_p27/lib/python2.7/site-packages/IPython/core/magic.pyc in <lambda>(f, *a, **k)
    186     # but it's overkill for just that one bit of state.
    187     def magic_deco(arg):
--> 188         call = lambda f, *a, **k: f(*a, **k)
    189 
    190         if callable(arg):

/home/ec2-user/anaconda3/envs/mxnet_p27/lib/python2.7/site-packages/IPython/core/magics/execution.pyc in time(self, line, cell, local_ns)
   1183         else:
   1184             st = clock2()
-> 1185             exec(code, glob, local_ns)
   1186             end = clock2()
   1187             out = None

<timed exec> in <module>()

/home/ec2-user/anaconda3/envs/mxnet_p27/lib/python2.7/site-packages/EXASOL/__init__.pyc in __init__(self, url, username, password, autocommit, queryTimeout, useCompression, typeMapper)
    324         self._inconnect = False
    325         self._type_mapper = typeMapper
--> 326         self._connect()
    327         self._login()
    328 

/home/ec2-user/anaconda3/envs/mxnet_p27/lib/python2.7/site-packages/EXASOL/__init__.pyc in _connect(self)
    417                 self._ws_send = self.__ws.send
    418                 self._ws_recv = self.__ws.recv
--> 419                 ret = self._req(command = 'login', protocolVersion = 1)
    420                 if CRYPTO_LIB == 'rsa':
    421                     if sys.version_info.major >= 3:

/home/ec2-user/anaconda3/envs/mxnet_p27/lib/python2.7/site-packages/EXASOL/__init__.pyc in _req(self, **req)
    407             raise OperationalError('%s [%s] %s' % ('database error',
    408                                                    rep['exception']['sqlCode'],
--> 409                                                    rep['exception']['text']))
    410         raise OperationalError('internal error: %s' % repr(rep))
    411 

OperationalError: database error [08004] Connection exception - Client connection must be encrypted.

1 个答案:

答案 0 :(得分:0)

PyEXASOL驱动程序支持WebSocket协议和HTTP传输的加密。

您需要做的就是将 encryption = True 传递给连接选项。