xeus-sqlite-kernel icon indicating copy to clipboard operation
xeus-sqlite-kernel copied to clipboard

Loading SQLite databases from a remote URL

Open psychemedia opened this issue 3 years ago • 6 comments

The jupyterlite/xeus-sqlite-kernel currently seems to require users to create a database as part of a script before they can query it, rather than connect to a sqlite file shipped as part of a JuptyerLite distribution or uploaded to it, or connect to a remote database file.

The phiresky/sql.js-httpvfs Javascript package wraps a SQLite emscripten distribution and also provides a virtual filesystem that allows the SQLite database to access very large remote SQLite databases (if configured appropriately) in an efficient way.

I wonder if this approach could be used to support remote connections from the xeus-sqlite-kernel? Users could then use a simple web server to publish both the JupyterLite environment, and even a large database, and then query the database efficiently from their browser?

The SQLime browser based SQlite playground (nalgeon/sqlime) also offers some interesting "web integrations", as described on its About SQLime page. For example, SQL files can be hosted Github gists, the gist id passed via a URL parameter to SQLime, then loaded and run by the playground when the page is loaded. (Databases files can also be uploaded from the desktop to the playground environment.)

image

The Basthon in-browser notebook [repo] & SQLite kernel loads a database from a file path specified via a URL parameter:

image

(I also note here examples of using custom javascript functions to create custom sqlite functions.)

psychemedia avatar Feb 07 '22 14:02 psychemedia

@psychemedia there is a PR here https://github.com/jupyter-xeus/xeus-sqlite/pull/119 with that one can fetch databases with %FETCH <URL> <FILENAME> and load them with %LOAD <FILENAME> RW one can then persist the virtual filesystem into the browsers indexed db, that way one only needs to do the fetching once

DerThorsten avatar Feb 07 '22 15:02 DerThorsten

Interesting, thanks..:-)

I take it that downloads the whole db, eg compared to the sql.js-httpvfs approach where the idea is you can connect to large remote databases and then just pull what you need chunks at a time?

Still v. useful though :-)

psychemedia avatar Feb 07 '22 17:02 psychemedia

Is it worth closing this, now https://github.com/jupyter-xeus/xeus-sqlite/pull/119 has been released? :eyes:

jamietanna avatar Dec 27 '23 16:12 jamietanna