question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Exception with `%config SqlMagic.autopandas=True`

See original GitHub issue
%config SqlMagic.autopandas=True
%%sql
SELECT 1 AS one
Done.
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-19-5d9ee192c327> in <module>()
----> 1 get_ipython().run_cell_magic('sql', '', 'SELECT 1 AS one')

/home/miki/playground/nbext/cenv/lib/python3.5/site-packages/IPython/core/interactiveshell.py in run_cell_magic(self, magic_name, line, cell)
   2113             magic_arg_s = self.var_expand(line, stack_depth)
   2114             with self.builtin_trap:
-> 2115                 result = fn(magic_arg_s, cell)
   2116             return result
   2117 

<decorator-gen-123> in execute(self, line, cell, local_ns)

/home/miki/playground/nbext/cenv/lib/python3.5/site-packages/IPython/core/magic.py 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):

<decorator-gen-122> in execute(self, line, cell, local_ns)

/home/miki/playground/nbext/cenv/lib/python3.5/site-packages/IPython/core/magic.py 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/miki/playground/nbext/cenv/lib/python3.5/site-packages/sql/magic.py in execute(self, line, cell, local_ns)
     87             result = sql.run.run(conn, parsed['sql'], self, user_ns)
     88 
---> 89             if result and ~isinstance(result, str) and self.column_local_vars:
     90                 #Instead of returning values, set variables directly in the
     91                 #users namespace. Variable names given by column names

/home/miki/playground/nbext/cenv/lib/python3.5/site-packages/pandas/core/generic.py in __nonzero__(self)
    915         raise ValueError("The truth value of a {0} is ambiguous. "
    916                          "Use a.empty, a.bool(), a.item(), a.any() or a.all()."
--> 917                          .format(self.__class__.__name__))
    918 
    919     __bool__ = __nonzero__

ValueError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:6

github_iconTop GitHub Comments

3reactions
gcbeltraminicommented, Jun 23, 2017

Fixed in commit b52e09a.

As of now, PyPI doesn’t have this fix, but you can install the latest (and fixed) version with:

$ git clone git@github.com:catherinedevlin/ipython-sql.git
$ cd ipython-sql/
$ pip install .

or

$ pip install git+git://github.com/catherinedevlin/ipython-sql.git

or

$ pip install git+https://github.com/catherinedevlin/ipython-sql.git

(edited after https://github.com/catherinedevlin/ipython-sql/issues/67#issuecomment-298316969)

1reaction
kellingtoncommented, Mar 8, 2017

I do not believe that this is fixed. The attached notebook is a very simple case - basis SQL works. However, with autopandas=True, you get error. SQL Magic Test Py3.ipynb.zip sql_magic_test_py3

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jupyter notebook: disable autocommit when using the %sql ...
Addendum, when I use the %config SqlMagic.autocommit=False option, I have: UserWarning: Config option autocommit not recognized by SqlMagic .
Read more >
Jupyter Magics with SQL - Towards Data Science
Let's explore Jupyter SQL magic that allows us to interact with Presto or ... %config SqlMagic.autocommit=False # for engines that do not ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found