by yurisagalov on 12/15/22, 3:59 PM with 46 comments
by kiwicopple on 12/15/22, 4:02 PM
this one might be more in of a “Show HN” because it’s a pre-release - something that you might want to try yourself or contribute to. The GitHub repo is here: https://github.com/supabase/wrappers
For context, Postgres has Foreign Data Wrappers (FDW) [0]. These allow you to connect one Postgres database to another, and then query the secondary database directly in the first.
CREATE FOREIGN TABLE other_database_table (
id integer,
title text
)
SERVER other_database;
The data does not need to be “moved” to the primary database - it stays in the secondary and is fetched when you run a select query: select * from other_database_table;
Our release today is a framework which extends this functionality to other databases/systems. If you’re familiar with Multicorn[1] or Steampipe[2], then it’s very similar. The framework is written in Rust, using the excellent pgx[3].We have developed FDWs for Stripe, Firebase, BigQuery, Clickhouse, and Airtable - all in various pre-release states. We'll focus on the systems we’re using internally while we stabalize the framework.
There’s a lot in the blog post into our goals for this release. It’s early, but one of the things I’m most excited about.
[0] Postgres FDW: https://www.postgresql.org/docs/current/sql-createforeigndat...
[1] Multicorn: https://multicorn.org/
[2] Steampipe: https://steampipe.io/
[2] pgx: https://github.com/tcdi/pgx
by atonse on 12/15/22, 4:16 PM
I love the pragmatism behind tools like osquery and steampipe that expose a lot of APIs as database tables. It makes these datasets available to non-programmers that are more comfortable with a database/tabular format.
Is it fair to say though, that FDWs have to run as compiled shared libs? I've always wondered if there can be (like with VS code and language servers) a protocol where we can run a generic FDW that speaks a particular API over the network, and then you can build out-of-process connectors to it and just have to know the usual tools (HTTP, JSON, etc).
Thoughts? Maybe this already exists.
Then anyone could potentially build a bespoke API/dataset and just point an FDW to it.
by sisve on 12/15/22, 9:20 PM
On a sidenote, is not the wrappers for Airtable, BigQuery and ClickHouse opensourced? Or why did they skip that column in the second table?
Is all of supabase opensourced now? I'm meaning I heard something about function not being opensourced but I can be remembering wrong. Most stuff is on GitHub I see
by nixalaister on 12/15/22, 5:02 PM
disclaimer: I am a Supabase employee, but these views are my own.
by claytongulick on 12/15/22, 6:24 PM
I'm not sure about this one though - rust is a great systems language, but it wouldn't be my first choice for bridging the db <-> api gap.
I wonder why this wasn't built on top of, or an enhancement to, the existing (excellent) multicorn[1] project. Python seems like a better choice of language for dealing with io bound problems like talking to remote APIs.
Multicorn is mature, stable, well tested and has a ton of FDW implementations already.
The dynamic nature of python simplifies the development/debug cycle, and serialization to/from JSON is easier than in any mainstream language except for javascript.
I'd love to understand more about the technical rationale that drove this.
by abuehrle on 12/15/22, 5:52 PM
by thedangler on 12/15/22, 4:19 PM
I can now use this instead of creating my own workflow to get the data via an api which will be stored in the DB anyways?
by jzelinskie on 12/15/22, 4:41 PM
Because RDS, for example, will only support the foreign data wrapper for reading from another "Postgres", what we really need is a server that supports the Postgres wire protocol (easier said than done) and you implement your drivers as a handler to that server.
by jansommer on 12/16/22, 8:28 PM
by spankalee on 12/15/22, 10:54 PM
Also, is the Firebase connector for Realtime Database or Firestore?
by dennisy on 12/15/22, 8:03 PM
But what is the point? Why is this better than making the API call?
SQL is for queries, why would I want to do networking with it?