Building apps in Neptyne often involves acquiring data from other places and a lot of data these days resides in postgres databases. Luckily connecting to a Postgres instance and querying databases is really straightforward. Let’s dive in. We’ll start with a little bit of config:
We import the postgres database library pg8000 and set up some connection information. This uses a database we have created so you’d need to insert your own information. If you are doing anything non-trivial, make sure to not put the password here in clear text but use neptyne’s secret management
Running a query is also not hard:
This yields first the headers and then the rows of the resulting query, something we can call directly from our spreadsheet:
C3 calls query on C2 so any time we change the query in C2 we immediately see the results below. Try it out at: