Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle SQL statements without rows returned #191

Open
yolile opened this issue Apr 16, 2021 · 1 comment
Open

Handle SQL statements without rows returned #191

yolile opened this issue Apr 16, 2021 · 1 comment

Comments

@yolile
Copy link

yolile commented Apr 16, 2021

Currently, if you run a SQL query that doesn't return rows (set, inserts, updates, etc), you got an exception, as reported here, because this line expects to get a result set

resultset = ResultSet(result, statement, config)

Ideally, it should handle statements without rows returned, or add a special case for queries starting with the word "set", as mentioned here.

@jsalbr
Copy link

jsalbr commented Apr 22, 2021

Hi, I got the same issue.

The problem is really critical because not even a use mydb works.
The error message is

ResourceClosedError: This result object does not return rows. It has been closed automatically.

The problem was introduced by sqlalchemy 1.4.

A workaround is:

!pip install "sqlalchemy<1.4"

But it would be great if you could make ipython-sql compatible to sqlalchemy 1.4 again.

Steps to reproduce:

%load_ext sql

%sql create table dummy(x int)

I created a reproducable example including the workaround on colab:
https://colab.research.google.com/gist/jsalbr/d4d280f1a68521071bf623427e9a1abd/ipython-sql_issue191.ipynb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants