Skip to content

Commit 0faca16

Browse files
Merge pull request #83 from potix2/support-impyla
Add autocommit setting to connect HiveServer2 with impyla
2 parents 8631c85 + bf48548 commit 0faca16

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

README.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,13 @@ to specify it in the connection string::
154154

155155
mysql+pymysql://scott:tiger@localhost/foo?charset=utf8
156156

157+
Note that ``impala`` connecion with `impyla`_ for HiveServer2 requires to disable autocommit::
158+
159+
%config SqlMagic.autocommit=False
160+
%sql impala://hserverhost:port/default?kerberos_service_name=hive&auth_mechanism=GSSAPI
161+
162+
.. _impyla: https://github.com/cloudera/impyla
163+
157164
Configuration
158165
-------------
159166

@@ -169,6 +176,9 @@ only the screen display is truncated.
169176
In [2]: %config SqlMagic
170177
SqlMagic options
171178
--------------
179+
SqlMagic.autocommit=<Bool>
180+
Current: True
181+
Set autocommit mode
172182
SqlMagic.autolimit=<Int>
173183
Current: 0
174184
Automatically limit the size of the returned result sets

src/sql/magic.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class SqlMagic(Magics, Configurable):
3737
"When the first argument is of the form [section], "
3838
"a sqlalchemy connection string is formed from the "
3939
"matching section in the DSN file.")
40+
autocommit = Bool(True, config=True, help="Set autocommit mode")
4041

4142

4243
def __init__(self, shell):

src/sql/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ def run(conn, sql, config, user_namespace):
302302
result = conn.session.execute(txt, user_namespace)
303303
try:
304304
# mssql has autocommit
305-
if 'mssql' not in str(conn.dialect):
305+
if config.autocommit and ('mssql' not in str(conn.dialect)):
306306
conn.session.execute('commit')
307307
except sqlalchemy.exc.OperationalError:
308308
pass # not all engines can commit

0 commit comments

Comments
 (0)