This is my new project that adds an interactive read-only SQL querying interface to any Django+PostgreSQL project.
The interface is protected by Django authentication: you can execute one or more SQL queries, copy the URL and share it with your collaborators on that project.
You can also create a saved dashboard and make that available to the wider world. Here are a couple of examples of saved dashboards that I'm running on my personal blog:
Very cool! I wrote Django SQL Explorer[0], and this looks very similar in spirit, but an emphasis on visualization that Explorer does not have (to the extent it has a focus, it's more on providing a reasonable way to write complex queries and re-use them).
I'm embarrassed to say I hadn't run across django-sql-explorer when I started working on this - that could have saved me a bunch of time, it looks really good!
That said, part of my rationale for building this was as a learning and research exercise since I need to learn more about read-only PostgreSQL for my Datasette project.
Definitely looking forward to cross-pollinating ideas. I agree, having access to this kind of interface is a massive productivity boost.
I use Django SQL Explorer pretty much every day. It's been wonderful for my needs. I'm also very happy to see django sql dashboard as an alternative and in particular the dashboard features like vega chart and markdown integration. I will definitely check this out. Thanks to both of you!
I have used Django SQL Explorer and it's fantastic, thank you for your work! It worked very well and is a great way to allow people to perform read-only queries, save them, run them later, etc. It was great for allowing non-technical people to quickly read data from the database.
I'm a happy Django sql explorer user (and small contributor) and I would like to say thank you for this project and totally recommend it to everybody! Django sql explorer makes it really easy to add arbitrary sql querying to your project with various other goodies!
I've had a lot of success with http://redash.io, which is a similar (though much more complex) project. SQL backend +visualizations can be really powerful and surprisingly flexible for building dashboards that aren't quite ad-hoc, but don't deserve their own standalone app and you just need to tie some input fields into SQL parameters.
Amazing project! It's the tool that I've been missing for many years. I was a contractor for almost 7 years and most of my clients were small companies that were paying for software to avoid hiring extra staff that would crunch numbers and tell what they mean. Setting up a dedicated BI tool is often overkill, compared to the actual reporting a small business needs. This is the perfect tool for a Djangonaut to set up raw SQL queries and allow users to interact with them.
Reading the docs it looks like if you have a read-replica of your primary database you could set `EXPLORER_CONNECTIONS` to only contain the read-replica and achieve some additional safety that way.
Read replicas are pretty easy to set up with most managed database products (Cloud SQL, AWS RDS), so that would be a very lightweight way to add some ad-hoc querying capabilities in prod that won't keep you up at night.
If you don't want to give your users direct access to your database using SQL, I wrote a little tool that basically exposes the ORM as a user interface and lets users query that way.
Naive question from someone with a superficial understanding of Django- I thought the advantage of Django was to abstract away from SQL through Class/Model so you don't need to write these queries? I can't quite tell what the use case would be here
This tool is aimed at mainly administrative folks who want to understand what's going on in their app/company by looking directly at data. Those folks are usually sql oriented, and you can build any ad-hoc query to do pretty deep analysis in sql. That's why being able to visualize things is also key here. Usually you'd do this in an OLAP db but this is a nice "poor mans" way for at least checking out what's going on without switching too much context.
This should run IPython Notebook with database models already imported :
python manage.py shell_plus --notebook
But writing fixtures, tests and (celery / dask-labextension) tasks is probably the better way to do things. Django-rest-assured is one way to get a tested REST API with DRF and e.g. factory_boy for generating test data.
[+] [-] simonw|4 years ago|reply
The interface is protected by Django authentication: you can execute one or more SQL queries, copy the URL and share it with your collaborators on that project.
You can also create a saved dashboard and make that available to the wider world. Here are a couple of examples of saved dashboards that I'm running on my personal blog:
https://simonwillison.net/dashboard/tag-cloud/
https://simonwillison.net/dashboard/code-examples/?search=re...
[+] [-] vidar|4 years ago|reply
[+] [-] numlocked|4 years ago|reply
These types of tools are extremely handy.
[0] https://github.com/groveco/django-sql-explorer
[+] [-] simonw|4 years ago|reply
That said, part of my rationale for building this was as a learning and research exercise since I need to learn more about read-only PostgreSQL for my Datasette project.
Definitely looking forward to cross-pollinating ideas. I agree, having access to this kind of interface is a massive productivity boost.
[+] [-] bytesmith|4 years ago|reply
[+] [-] StavrosK|4 years ago|reply
[+] [-] spapas82|4 years ago|reply
[+] [-] uk123|4 years ago|reply
[+] [-] roywiggins|4 years ago|reply
I've had a lot of success with http://redash.io, which is a similar (though much more complex) project. SQL backend +visualizations can be really powerful and surprisingly flexible for building dashboards that aren't quite ad-hoc, but don't deserve their own standalone app and you just need to tie some input fields into SQL parameters.
[+] [-] artiscode|4 years ago|reply
edit: Added Djangonaut mention
[+] [-] pgt|4 years ago|reply
[+] [-] pyrophane|4 years ago|reply
Read replicas are pretty easy to set up with most managed database products (Cloud SQL, AWS RDS), so that would be a very lightweight way to add some ad-hoc querying capabilities in prod that won't keep you up at night.
[+] [-] legostormtroopr|4 years ago|reply
https://github.com/Aristotle-Metadata-Enterprises/django-dat...
[+] [-] TruthWillHurt|4 years ago|reply
[+] [-] stuartbman|4 years ago|reply
[+] [-] berto4|4 years ago|reply
[+] [-] simonw|4 years ago|reply
The key feature here is that you can build a new report without having to write any Python/Django code at all.
[+] [-] stanislavb|4 years ago|reply
[+] [-] dacox|4 years ago|reply
I know Jupyter exists - but a solution like this with the permissions would be valuable.
[+] [-] westurner|4 years ago|reply
This should run IPython Notebook with database models already imported :
But writing fixtures, tests and (celery / dask-labextension) tasks is probably the better way to do things. Django-rest-assured is one way to get a tested REST API with DRF and e.g. factory_boy for generating test data.[+] [-] photojosh|4 years ago|reply
[+] [-] avinassh|4 years ago|reply
The buttons also reminded me of Goat Counter which also employs the minimal CSS things
[+] [-] simonw|4 years ago|reply
[+] [-] nickphx|4 years ago|reply
[+] [-] coder13|4 years ago|reply