Skip to content

Handle SQL statements without rows returned #191

Open

Description

@yolile

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.

Activity

  1. jsalbr commented on Apr 22, 2021

    @jsalbr

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions