jupyterlite / jupyterlite

Wasm powered Jupyter running in the browser 💡
https://jupyterlite.rtfd.io/en/stable/try/lab
BSD 3-Clause "New" or "Revised" License
3.84k stars 293 forks source link

Accessing postgres database from python kernel #1083

Open butsuri43 opened 1 year ago

butsuri43 commented 1 year ago

Problem

Accessing Postgres database from jupyterlite (pyodide).

I would like to start a discussion what is currently possible and what are potential options for the future.

Suggested Improvement

I have been experimenting with this and here is what I found:

Are there any options available?

oscar6echo commented 1 year ago

@butsuri43
In my view the easiest and most scalable solution is to convert SQL to GraphQL.

How ? The (or at least one of the) most popular and battle tested GraphQL engine is hasura.
It is open source and I made a demo repo PostgreSQL + Hasura + JupyterLab | JupyterLite for local testing:

We use it in production, so I can confidently assert that hasura is a fine piece of software - and so is JupyterLite :smiley:

cc @jtpio as making databases accessible from JupyterLite was the subject of a conversation at JupyterCon.

jtpio commented 1 year ago

Thanks @butsuri43 and @oscar6echo.

Having a guide in the JupyterLite documentation to provide pointers for such use cases would be great. This is not a feature that needs to be implemented in JupyterLite directly, and it could likely be used in JupyterLab for example.

It is open source and I made a demo repo PostgreSQL + Hasura + JupyterLab | JupyterLite for local testing:

Thanks for sharing! The link seems to be giving a 404 at the moment though.

oscar6echo commented 1 year ago

Oups - it was a private repo - now public - bad habit from corp world..

Indeed this is a JupyterLite topic as far as user workflows should be catered to, but it is completely separate in terms of implementation.

Note that this topic - accessing database through api - is not unrelated to the broad authentication topic, which should (partially) be implemented in JupyterLite (custom deployments).