-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generating CSV file upon GET request with appropriate headers #226
Comments
This is an excellent feature, I'd love your help with it. Your approach of using the Accept header in the request sounds perfect. The issue in Hasql with copy mode came up when I was trying to do bulk inserts. Bulk reads may or may not be easier. For the inserts I ultimately made a workaround by using an insert command with multiple values (suboptimal because not as fast as copy). |
I would also like this feature with a slight difference. I would rather not have users download CSV files and import them. Instead setting content type to text/csv and returning comma separated rows instead of JSON. This way I can call the services from excel and return directly into a workbook utilizing excel's background refresh capabilities. |
@begriffs unfortunately I've been trying to implement COPY support in hasql-postgres without success. So I was wondering if you would be willing to integrate a PR with this feature using a SELECT statement. |
I will gladly help to implement this one and I'd like to know if it's a desirable feature.
My use case is: I want to make some query results available as a CSV for my users, so that they can use this data in spreadsheets.
Possible solutions: I could bring the data in JSON format from PostgREST and assemble a CSV in the browser. But it seems that we could benefit from PostgreSQL amazing performance when executing
COPY
queries to generate a CSV in the backend. Besides the client-side solution impedes interoperability with other clients that might expect a CSV file.My proposal: We use the content type provided in the request when executing a GET (this is also useful for a POST but stating with GET sounds easier). If the content type matches
text/csv
we use the same where clause generated for the JSON response but plug it in aCOPY
statement.@begriffs I've noticed you've opened this issue: nikita-volkov/hasql#1 so I guess that there are changes in hasql-postgres needed before anyone can implement this in PostgREST right?
The text was updated successfully, but these errors were encountered: