MariaDB / mariadb_kernel

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

can't exec SQL #32

Closed xdewx closed 2 years ago

xdewx commented 2 years ago
[IPKernelApp] ERROR | Exception in message handler:
Traceback (most recent call last):
  File "/opt/conda/lib/python3.9/site-packages/ipykernel/kernelbase.py", line 353, in dispatch_shell
    await result
  File "/opt/conda/lib/python3.9/site-packages/ipykernel/kernelbase.py", line 643, in execute_request
    reply_content = self.do_execute(
  File "/opt/conda/lib/python3.9/site-packages/mariadb_kernel/kernel.py", line 117, in do_execute
    result = self.mariadb_client.run_statement(s)
  File "/opt/conda/lib/python3.9/site-packages/mariadb_kernel/mariadb_client.py", line 107, in run_statement
    result = self.maria_repl.run_command(code, timeout)
AttributeError: 'NoneType' object has no attribute 'run_command'
robertbindar commented 2 years ago

Hey @xdandyx! Sorry for the delay, I've totally missed the notification for this issue. Can you please provide more details on how this exception occurs?

xdewx commented 2 years ago
[IPKernelApp] Loading config file at /home/jovyan/.jupyter/mariadb_config.json...
[IPKernelApp] ERROR | No mariadb> command line client found at ;
[IPKernelApp] ERROR | Please install MariaDB from mariadb.org/download
[I 2021-11-29 05:35:55.431 ServerApp] Starting buffering for 54b37767-9e3e-42b0-84f9-d89564cb8d19:73b9a4de-45a0-425b-af3f-aa1825cf418a
[IPKernelApp] ERROR | Exception in message handler:
Traceback (most recent call last):
  File "/opt/conda/lib/python3.9/site-packages/ipykernel/kernelbase.py", line 353, in dispatch_shell
    await result
  File "/opt/conda/lib/python3.9/site-packages/ipykernel/kernelbase.py", line 643, in execute_request
    reply_content = self.do_execute(
  File "/opt/conda/lib/python3.9/site-packages/mariadb_kernel/kernel.py", line 117, in do_execute
    result = self.mariadb_client.run_statement(s)
  File "/opt/conda/lib/python3.9/site-packages/mariadb_kernel/mariadb_client.py", line 107, in run_statement
    result = self.maria_repl.run_command(code, timeout)
AttributeError: 'NoneType' object has no attribute 'run_command'

@robertbindar this is the full message i got. And my mariadb_config is as follow:

{
    "user": "root",
    "host": "xxxx.xxx.xx.xx",
    "port": 3306,
    "password": "mypasswd",
    "start_server":"False",
    "client_bin":"",
    "server_bin":""
}
robertbindar commented 2 years ago

Hey @xdandyx! If you see at the beginning of the log you sent me above, mariadb_kernel couldn't find MariaDB binaries (client and server) on your system. From looking at the .json file you provided, it seems you are passing client_bin and server_bin equal to "" which is not a valid path for MariaDB binaries. Because you passed start_server: False, I'm guessing you started your own MariaDB server and you want the kernel to connect to that instance. So my suggestion is you remove server_bin option at all because with start_server:False, the kernel doesn't need it and you also provide a correct path in client_bin option (if MariaDB is installed system wide, you can even remove the option and the kernel will look up the MariaDB client by "mariadb" binary name in $PATH).

robertbindar commented 2 years ago

Let me know please if this suggestion fixes the problem for you, and thanks a lot for raising this issue here!

xdewx commented 2 years ago

Hey @xdandyx! If you see at the beginning of the log you sent me above, mariadb_kernel couldn't find MariaDB binaries (client and server) on your system. From looking at the .json file you provided, it seems you are passing client_bin and server_bin equal to "" which is not a valid path for MariaDB binaries. Because you passed start_server: False, I'm guessing you started your own MariaDB server and you want the kernel to connect to that instance. So my suggestion is you remove server_bin option at all because with start_server:False, the kernel doesn't need it and you also provide a correct path in client_bin option (if MariaDB is installed system wide, you can even remove the option and the kernel will look up the MariaDB client by "mariadb" binary name in $PATH).

@robertbindar Thank u very much ! Finally, the problem is solved following your suggestion.

It's confusing that start_server:False also need mariadb_client to be installed. I thought there is no need to install mariadb-client & mariadb-server when i use a remote mariadb_server instance (so there is no mariadb-bin installed in my os). However , the result turns out i was wrong.

Shouldn't it just use libmariadb-dev & mariadb_kernel to connect to the remote database?

robertbindar commented 2 years ago

Hey @xdandyx! I'm very happy the problem is fixed for you now :-) mariadb_kernel currently uses the mariadb binaries to connect no matter if connection happens remote or locally. This is indeed something that is going to change in the future because the library we are currently using to control mariadb> limits us on Windows. So a new client will be developed based on an independent library implementation of the client protocol.

robertbindar commented 2 years ago

Closing this as problem is resolved. @xdandyx if you need further help, feel free to open another one or reopen this