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
Additional export functionality #186
Comments
Totally up for it -- JSON in particular would be nice. I think we should revisit the URL endpoints if this is to be done -- e.g. currently there are: /download these should probably be changed to: /download?format= with the default format being .csv. What do you think? I'd also ask that any heavy dependencies (like an Excel integration, PDF, etc) be optional and the code respond according to whether those dependencies are installed. I think one of the appeals of Explorer is the low number of dependencies and I'd like to take the optional route when possible. Happy to help with the code as well if we want to get a branch going with it. |
I like it. The change to those URLs would probably constitute a backwards-incompatible change. Do you think perhaps this new feature would be worthy of making django-sql-explorer 1.0.0? I like the idea of making dependencies optional (Excel and PDF functionality, specifically). CSV and JSON (and XML?) export could use Python stdlib modules. Another feature to consider could be adding custom exporters via settings, e.g.
Probably getting ahead of myself here. That definitely doesn't need to be in the initial release. Just something to consider. 😄 I think creating a new branch would be wise. Maybe a |
@chrisclark How do you typically develop django-sql-explorer? I'm trying to do the ol' |
I run it in a project that isn't in git. I just spun up a sample project in
This will run migrations on sqlite, create a superuser with u/p I was also thinking that 'open in google sheets' would be a good export -Chris On Mon, Mar 21, 2016 at 7:24 AM, Grant McConnaughey <
Chris Clark │ Grove Co. │ 617-571-7327 1770 Union St, San Francisco, CA |
I see. I created a little test project on my machine and I'm using that to access the explorer. I have JSON, CSV, and Excel export functionality currently. I haven't done anything with streaming (which I honestly wouldn't know how to do) or emailing. Would you like me to push to my fork so you can take a look at my implementation? Also, open in google sheets could probably work, although that might be different type of exporter than I'm creating. Right now, the "Data Exporters" (as I'm calling them) simply take a query and generate the response that downloads the file: CSV, JSON, or Excel. |
Yep -- go ahead and give it a push and I will take a look. By 'streaming' i Super easy. I'll take a look at email as well. Should be able to replicate On Tue, Mar 22, 2016 at 12:37 PM, Grant McConnaughey <
Chris Clark │ Grove Co. │ 617-571-7327 1770 Union St, San Francisco, CA |
Okay, @chrisclark, I have a branch on my fork that has the data exporter functionality. It's definitely not complete. I only have the following endpoints:
I don't have stream or email functionality done yet. I am also not finished with the implementation. Check out I'm trying to think of ways to make this a little more generic and less coupled between exporter/response. Maybe responses could be created in a view and exporters can just be responsible for writing their data to that response and returning it? Like so: def download_view(request, query_id):
# Get the query, add params, etc.
exporter = ExporterClass(query)
response = HttpResponse()
exporter.write_to_response(response)
return response Or perhaps exporters could just write their data to a def download_view(request, query_id):
# Get the query, add params, etc.
exporter = ExporterClass(query)
output = exporter.output() # This returns a StringIO or BytesIO in-memory buffer
return HttpResponse(output, content_type=exporter.content_type) I'm leaning towards the latter. What do you think? |
I went ahead and refactored to the second option. Views now handle creating the response and exporters handle generating the response content. I've also added a |
Any news on this feature? Need help? I desperately need xlsx export functionality. CSV is giving wrong encoding for excel to parse. |
@pkaczynski -- check out the data_exporters branch. It'll get merged to master by the end of this week and I'll then do a release. It has XLSX export functionality :) |
Thanks for that! Will you issue new release soon? |
Hey @chrisclark, did this ever get released? I thought it did but I just checked PyPI and version 0.9.2 is the most recent version. Just checking. Take care! |
@grantmcconnaughey working on it now! I have to do all the documentation, etc. |
Hey @chrisclark, what do you think about updating the export functionality to export to CSV, Excel, PDF, and JSON? Maybe a nice little toolbar below the report with export functionality to any of those choices. Then more could be added later if necessary (like an HTML Table export or something).
I would of course help out with this. Just wanted to get your opinion first.
The text was updated successfully, but these errors were encountered: