Connect to SQLite
Upload your database to Nextjournal. For more information on this step, see Working With Data.
Mount the database in the runtime settings. Mounts are configured in a runtime's settings under Mounts. Click the gear button next to the runtime name in the sidebar to reveal this menu:
See Runtime Settings for documentation on all runner settings.
This example uses
sqlite3 in Python to connect to SQLite but similar packages exist for most languages, including Julia, R, and Clojure.
The fetch returns a list of tuples. Queries can be turned into a Pandas DataFrame, which is easier to manipulate and plot.
Connect to Postgres
Google Cloud SQL
Please make sure your Google Cloud SQL instance accepts connections on public ip and note the public ip as shown in https://console.cloud.google.com/sql/instances. Use this public ip as HOSTNAME later in this example.
Also please add the following two IPs to the "Public IP - Authorized networks" setting of your Google Cloud SQL instance.
Install Psycopg to connect to PostgreSQL using Python. Similar packages exist for most languages, including Julia, R, and Clojure.
Postgres (Bash in Python)
Add the database credentials in the runtime settings under Environment Variables & Secrets. Click the gear button next to the runtime name in the sidebar to open the menu:
In particular, sensitive authentication credentials should be managed here. This feature requires a paid plan. Details can be found in Using Secrets.
Connect to the remote database using the credentials from the runner settings and then run/fetch the query.