bgschiller / postgres_kernel

A simple Jupyter kernel for PostgreSQL
MIT License
64 stars 19 forks source link

How to properly setup a connection? #16

Closed jlandercy closed 5 years ago

jlandercy commented 5 years ago

Maybe I have missed a simple thing, but...

I have installed postgres_kernel alongside jupyterhub, it has been integrated out of the box.

But when I start a notebook with this kernel, it just cannot connect any PostgreSQL databases running on my server.

I was wondering I had to edit a config file in order to supply connection strings but I have found nothing on internet about that. Even after digging into my disk, I do not found any config file. Could you tell me how to connect a PostgreSQL database using your kernel.

Thank you

bgschiller commented 5 years ago

My apologies, I could have sworn that was documented in the README. I'll try and add that sometime soon. You'll want to execute a cell with a connection string. For example,

--connection: postgresql://brian@localhost:5432/schedule_md

jlandercy commented 5 years ago

Thank you for answering and being reactive.

I am trying to add a comment line (-- SQL) with connection sting in the first cell but and execute it, but the connection still fails.

You can see bellow the process and the result:

snag1 snag2 snag3

I have checked my credentials they are ok. Digging deeper, I have found this in JupyterHub log using journalctl:

Nov 17 18:34:03 helena sudo[623]: Traceback (most recent call last):
Nov 17 18:34:03 helena sudo[623]:   File "/usr/lib/python3.5/runpy.py", line 183, in _run_module_as_main
Nov 17 18:34:03 helena sudo[623]:     mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
Nov 17 18:34:03 helena sudo[623]:   File "/usr/lib/python3.5/runpy.py", line 142, in _get_module_details
Nov 17 18:34:03 helena sudo[623]:     return _get_module_details(pkg_main_name, error)
Nov 17 18:34:03 helena sudo[623]:   File "/usr/lib/python3.5/runpy.py", line 109, in _get_module_details
Nov 17 18:34:03 helena sudo[623]:     __import__(pkg_name)
Nov 17 18:34:03 helena sudo[623]:   File "/usr/local/lib/python3.5/dist-packages/postgres_kernel/__init__.py", line 1, in <module>
Nov 17 18:34:03 helena sudo[623]:     from version import __version__
Nov 17 18:34:03 helena sudo[623]: ImportError: No module named 'version'

Then I just added a dot before version keyword:

from .version import __version__

And it worked...

It seems the pip repository (which I targeted for install) is not up-to-date with you git because on your github it is fixed. Thank you for sharing.

bgschiller commented 5 years ago

I'm glad you got it working, and thanks for telling me about the pip version being out of date! I'll update that soon as well.