How to store "bytea" data via query API?

The REST API is awesome as we can use it from Cloudflare Workers (and generally REST rocks:)
How can we upload binary blobs in columns using Execute a query?

Also could you please add a “bindings” parameter so that we can put “?” into the query string and actual values come from the JSON array in the bindings, kind of like Cliudflare’s D1 API:

Is anyone (other than us) using the REST API, are you actively improving it?


Yep, we’re actively improving it based on user feedback, so thanks for that.

WRT to bytea, the REST endpoint just takes a query string that’s fed to Postgres. So, whatever works for INSERTs generally should work. I think you can do something like:

  mytable (testcol)

More details and options:

For prepared statements, unlike the DI API, there’s no state in which to build a query. Could your provide an example HTTP REST call to the query endpoint you’d ideally like to use for prepared statements?

For bind we’d like to use something like what CloudflareD1 has:

so it’d be like:

"query_string": "INSERT INTO users (name, age) VALUES (?1, ?2)"
"bindings": ["John", 42]

The benefit of having bindings array separately from query_string is much better protection from SQL injection attack (i.e we don’t need to be very careful with escaping the inserted values), also much easier to understand what’s going on and debug.

?1 and ?2 syntax is not super important, plain “?” is enough.

Does this make sense?