Skip to content

Commit 17b3a8d

Browse files
2 parents f4283c6 + 0faca16 commit 17b3a8d

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

NEWS.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ Deleted Plugin import left behind in 0.2.2
7575
- Proper handling of configuration
7676

7777
* Added .DataFrame(), .pie(), .plot(), and .bar() methods to
78-
result sets
78+
result sets
7979

8080
0.3.0
8181
-----

README.rst

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,15 @@ or a single dictionary with a tuple of scalar values per key (``result.dict()``)
119119
Assignment
120120
----------
121121

122-
Ordinary IPython assignment works for single-line `%sql` queries::
122+
Ordinary IPython assignment works for single-line `%sql` queries:
123123

124124
.. code-block:: python
125125
126126
In [16]: works = %sql SELECT title, year FROM work
127127
43 rows affected.
128128
129129
The `<<` operator captures query results in a local variable, and
130-
can be used in multi-line ``%%sql``::
130+
can be used in multi-line ``%%sql``:
131131

132132
.. code-block:: python
133133
@@ -158,6 +158,13 @@ to specify it in the connection string::
158158

159159
mysql+pymysql://scott:tiger@localhost/foo?charset=utf8
160160

161+
Note that ``impala`` connecion with `impyla`_ for HiveServer2 requires to disable autocommit::
162+
163+
%config SqlMagic.autocommit=False
164+
%sql impala://hserverhost:port/default?kerberos_service_name=hive&auth_mechanism=GSSAPI
165+
166+
.. _impyla: https://github.com/cloudera/impyla
167+
161168
Configuration
162169
-------------
163170

@@ -173,6 +180,9 @@ only the screen display is truncated.
173180
In [2]: %config SqlMagic
174181
SqlMagic options
175182
--------------
183+
SqlMagic.autocommit=<Bool>
184+
Current: True
185+
Set autocommit mode
176186
SqlMagic.autolimit=<Int>
177187
Current: 0
178188
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)