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

ADD %%sqlnotice magic #1019

Closed
benabel opened this issue Jul 5, 2024 · 2 comments
Closed

ADD %%sqlnotice magic #1019

benabel opened this issue Jul 5, 2024 · 2 comments

Comments

@benabel
Copy link

benabel commented Jul 5, 2024

Hi, and thanks for this awesome open-source project:)

I'm using postgresql, and I would like to output notice.

do 
'declare
   film_count integer;
begin 
   select count(*) into film_count
   from film;

   raise notice ''The number of films: %'', film_count;
end;'
;

This can be done using the psycopg connection with poll method.

 # Check for notices
    connection.poll()
    while connection.notices:
        notice = connection.notices.pop(0)
        print("Notice: ", notice)

With this magic we would output the notices instead of results. Do you think it is worth doing it(my use case is for teaching).

@edublancas
Copy link

Hi Ben, thanks for your feedback.

Unfortunately, this is pretty niche, and the team doesn't have the bandwidth to work on it. You're welcome to fork the project and add the magic!

@edublancas edublancas closed this as not planned Won't fix, can't repro, duplicate, stale Jul 5, 2024
@benabel
Copy link
Author

benabel commented Jul 7, 2024

Thanks for your answer, I've tried to work on implementing this in the sql.run.run.run_statements function without a new magic and it seems not so easy to access the notices list. Best for your project.

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