Hacker News new | ask | show | jobs
by islandert 793 days ago
If you don't have access to COPY if the postgres instance is managed, I've had a lot of luck with encoding a batch of rows as a JSON string, sending the string as a single query parameter, and using `json_to_recordset` to turn the JSON back into a list of rows in the db.

I haven't compared how this performs compared to using a low-level sql library but it outperforms everything else I've tried in sqlalchemy.

1 comments

When I see suggestions like this (totally reasonable hack!), I do have to wonder what happened to JDBC’s “addBatch()/executeBatch()”, introduced over 25 years ago.

https://docs.oracle.com/javase/8/docs/api/java/sql/PreparedS...

Did modern APIs & protocols simply fail to carry this evolutionary strand forward?