hasql
hasql copied to clipboard
Support the COPY command
My app needs to bulk-load data and postgres' copy mode is the fastest way to do it. Postgresql-simple supports it with this. Would be great if this library did too.
Thanks for making hasql! I'll actually be switching over to it anyway, and the copy command would be the icing on the cake.
Thank you. Nice to hear.
It's actually the first time I had to read the docs on the COPY
command, so I'll need some clarifications.
I'm not sure what's stopping you from using it directly, e.g.:
H.unit $ [H.q| COPY table FROM filename |]
Well in my case the data will be coming in as a post to my web server and the database lives on another computer which does not have access to the web server filesystem. I'll need to send the data through the hasql connection.
If you're using libpq internally it has some functions for doing this: http://www.postgresql.org/docs/9.3/static/libpq-copy.html
A problem with this thing is that it only concerns Postgres, while Hasql is a general API.
I have some ideas concerning this feature though. One of them requires a major revision of the whole infrastructure of Hasql libraries and implementing this feature in the API of "hasql-postgres". Alternative idea is to introduce another class in "hasql-backend", which deals with this functionality in a general way, then drivers will optionally provide instances for that class depending on whether they support such functionality.
I like the first idea better, but I'll let it age for now. I will get back to this problem though when some other issues requiring a revision of the backend API will appear.
@nikita-volkov I'd love to help implementing this feature. Any thoughts on how to do it?
I think it should be done in the "hasql-postgres" library, since it is a Postgres-specific feature. Concerning ways of implementing it, I haven't considered it. 13 Июл 2015 г. 4:10 пользователь "Diogo Biazus" [email protected] написал:
@nikita-volkov https://github.com/nikita-volkov I'd love to help implementing this feature. Any thoughts on how to do it?
— Reply to this email directly or view it on GitHub https://github.com/nikita-volkov/hasql/issues/1#issuecomment-120778957.
You may wish to change the label of this repository then, which is currently "An efficient PostgreSQL driver and a flexible mapping API" (emphasis mine)
@ocharles Hasql is no longer general. It's now specialised to Postgres only, hence the label.
Ok, I thought that may be the case, but just wanted to check wrt the above comment.
If I were to implement this, in which way would I need to worry about the current dev branch?
@rightfold The dev branch represents the ongoing development of the next major release. It already is a complete reimplementation compared to "master" and probably will get more drastic changes applied. So if you want to contribute, you probably should just branch off from "master" and we'll figure something out about merging that into the new version, once it's stabilised.