Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: Django SQL Dashboard (datasette.io)
204 points by simonw 35 days ago | hide | past | favorite | 27 comments

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:



Using the Django auth is neat, how would you compare this to Metabase?

It's a lot less sophisticated than Metabase!

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).

These types of tools are extremely handy.

[0] https://github.com/groveco/django-sql-explorer

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!

Does django sql explorer work with a snowflake database?

This is cool!

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.

edit: Added Djangonaut mention

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.


I guess phpMyAdmin is out of fashion these days ;)

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.

Yeah, this would have replaced a fairly expensive SaaS subscription at my old job which simply allowed business-side folks the ability to run SQL queries safely (in theory).

This is all about ad-hoc reporting - it's basically a very lightweight business intelligence tool.

The key feature here is that you can build a new report without having to write any Python/Django code at all.

Seems nice. And, if you are in the Ruby (on Rails) ecosystem, I can highly recommend Blazer https://github.com/ankane/blazer

This looks great! In a similar vein - does anyone know of a project that will allow for a Django shell in the browser?

I know Jupyter exists - but a solution like this with the permissions would be valuable.

This launches the web-based Werkzeug debugger on Exception:

  pip install django-extensions
  python manage.py runserver_plus

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.

That is an excellent idea. The number of times I've fired up an SSH shell on my phone to do a quick fix for a client...

I love the minimal design. Which CSS framework do you use? Or is it self created?

The buttons also reminded me of Goat Counter which also employs the minimal CSS things

It's hand-written CSS - there's not much of it: https://github.com/simonw/django-sql-dashboard/blob/01bb7e60...

Nice work, thanks for sharing. The ability to create visualizations is a great feature.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact