MariaDB / mariadb_kernel

A MariaDB Jupyter kernel
BSD 3-Clause "New" or "Revised" License
30 stars 21 forks source link

Display a confirmation message for successful empty-result queries #15

Closed robertbindar closed 3 years ago

robertbindar commented 3 years ago

For queries such as create table t..., the kernel either displays an error if there is a problem with the query, or displays nothing if the query is correct. That is because such queries don't return a result set, so the kernel has nothing to display. But this is confusing to users as pointed by @cvicentiu, so we should display a Query OK message to let the user know that the execution is done and successful.

a97410985 commented 3 years ago

I want to solve this issue, can assign it to me? 😃

robertbindar commented 3 years ago

Feel free to work on it, thanks a lot for the help! Let me know if you need help with this, feel free to ask questions 😄

a97410985 commented 3 years ago

my ideas :

mariadb_kernel/kernel.py is reponsible for execute the code when frontend run a cell, and the function handle this is do_execute(...),which would parse sql and magic command and execute it. The following code for execute sql statements.

 # part of mariadb\_kernel/kernel.py
 statements = parser.get_sql()
 for s in statements:
     result = self.mariadb_client.run_statement(s)
     if self.mariadb_client.iserror():
        self._send_message("stderr", self.mariadb\_client.error\_message())
        continue
    self._update_data(result)
    display_content = {"data": {"text/html": str(result)}, "metadata": {}}
    if not silent:
        self.send_response(self.iopub_socket, "display_data", display_content)

when error occur, if self.mariadb_client.iserror(): will handle this. After that, if the result is empty we should display a pure text, show ''Query OK", make the user assure execution success

demonstration(video)

https://www.youtube.com/watch?v=-3GKlLQjwGA&ab_channel=%E6%B1%9F%E6%96%B0%E7%9F%A5

robertbindar commented 3 years ago

Fixed by @a97410985 in #21