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

try-except block for %%sql #198

Open
NimJ opened this issue Jul 26, 2021 · 0 comments
Open

try-except block for %%sql #198

NimJ opened this issue Jul 26, 2021 · 0 comments

Comments

@NimJ
Copy link

NimJ commented Jul 26, 2021

How can I handle exceptions under %%sql ?

Below statement works:

try:
    %sql DROP INDEX index_name;
    %sql CREATE INDEX index_name ON table_name(column1, column2);
except:
    %sql CREATE INDEX index_name ON table_name(column1, column2);

But, below statement fails with syntax error

try:
    %%sql
    DROP INDEX index_name;
    CREATE INDEX index_name ON table_name(column1, column2);
except:
    CREATE INDEX index_name ON table_name(column1, column2);`

image

Below statement fails too with error as shown below

%%sql
try:
    DROP INDEX index_name;
    CREATE INDEX index_name ON table_name(column1, column2);
except:
    CREATE INDEX index_name ON table_name(column1, column2);

image

pmfischer pushed a commit to pmfischer/ipython-sql that referenced this issue Sep 8, 2023
* Updating license

* Updating license
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

1 participant