Is there a DOC page for how to connect to Postgres?
Hey, there isn’t a doc page for this. I’ll ping @damion or @asa to put something together and share it here.
Can I just clarify the use case. Hypi includes a DB, you just create models and then use the CRUD APIs.
Are you connecting out because you have existing data in PG already?
Yeah, that’s the use case. I have a WordPress frontend, which takes an order, builds a JSON package, and sends it to some Python that parses and writes to a PG database. I would rather not switch backends at this point - everything connects to Posgres.
Probably doesn’t matter, but the database is on railway.app
Looking forward to an update on this.
Set Up a GraphQL Schema Using an Existing Postgres Database | Hasura GraphQL Docs - This level of automation sounds pretty awesome.
Hey, so we haven’t come back with something yet because we’ve been working out the best way to do this.
We’ve already deprecated OpenWhisk and we decided on Monday that we won’t accept any new customers on it. There is a replacement serverless framework, JavaScript, Python and Ruby scripts are supported by it.
Taking a bit long to share the example as it is not currently generally available so the team’s working on making it so. I expect that to happen in one of tomorrow’s or Fri’s releases. I’ll update and share some examples here after.
FYI we don’t have an equivalent to the link you posted you’d access your DB with something like this:
//there's a hypi.mysql and hypi.mariadb as well
const client = hypi.postgres("localhost", 5432, "user", "pass", "db name")
//hypi is a global variable made available automatically, it has an args field which is an object containing the arguments passed into the function
//select returns a list of objects, each object is a row, the key is the column name after being upper cased
client.select('SELECT ?::text as message', hypi.args.message)
We do pool and manage connections for you so you’re not incurring a connection overhead each function call