Announcing Django SQL Dashboard, now out of alpha and ready for people to try out on their own Django+PostgreSQL projects: simonwillison.net/2021/May/10/dj…
The key idea here is to bring some of the most valuable features of Datasette to any Django+PostgreSQL project
You can execute read-only SQL queries interactively, bookmark and share the results, and write queries that produce bar charts, progress bars and even word clouds too
I recorded a three minute video demo which shows the tool in action
My post includes a delightfully convoluted example: a SQL query which searches just the code examples I've posted to my blog, using a PostgreSQL regular expression to extract any <pre>...</pre> blocks and strip extraneous HTML!
I think this is the most interesting idea embedded in both Django SQL Dashboard and Datasette: the ability to build an entire custom application (in this case search within code examples) as a single bookmarkable SQL query
So much of what we do as web developers can be boiled down to building a custom, templated interface on top of the results of a SQL query - so being able to do that with a bookmark is an enormous productivity boost!
If anyone wants to create custom visualization widgets for this it's very straight-forward: create a new Django template with a filename that matches the columns you want to visualize: django-sql-dashboard.datasette.io/en/latest/widg…
Having this kind of interface available is a big productivity boost for maintenance development - means you can instantly answer questions like "how many people have used this feature?" or "are there any records exhibiting this edge-case?" - and link to the query from the issue
I find that for most of the coding I do these days I spend 80% of the time on research and 20% of the time on actually typing code - gathering notes on how things work using bookmarked SQL queries fits my development process really well
• • •
Missing some Tweet in this thread? You can try to
force a refresh
Out of interest: if you have a blob of JSON on your clipboard and you want to see a pretty-printed version of it, what's your fastest way to do that?
I hit Shift+Command+N in VSCode to get a new window, paste it in there, then hit Shift+Command+P to get the command palette, type JS and select the JSON pretty print option - which I think I installed as an extension at some point
Other times I'll use "pbpaste | jq", occasionally I'll use ipython like so:
s = """<paste JSON here>"""
import json
print(json.dumps(json.loads(s), indent=2))
What are the options for "serverless" PostgreSQL like these days? My definition of serverless here is that you don't have to spend any money at all if you're not getting any DB traffic, and cost then scales up as the traffic and storage you are using increases
Aurora PostgreSQL is the most obvious option, though it's not clear to me if you have to keep at least one instance running for it or if it fully "scales to zero" for projects that aren't receiving any traffic at all
Consensus in replies seems to be that this doesn't actually exist yet - scale-to-zero for a relational database server like PostgreSQL is evidently a whole lot harder than scale-to-zero for a stateless web application server as seen with things like Google Cloud Run
"Hosting SQLite databases on Github Pages" is absolutely brilliant: it adds a virtual filesystem to SQLite-compiled-to-WebAssembly in order to fetch pages from the database using HTTP range requests phiresky.github.io/blog/2021/host…
Check out this demo: I run the SQL query "select country_code, long_name from wdi_country order by rowid desc limit 100" and it fetches just 54.2KB of new data (across 49 small HTTP requests) to return 100 results - from a statically hosted database file that's 668.8MB!
Looks like the core magic here is only around 300 lines of (devastatingly clever) code github.com/phiresky/sql.j…
The feature I most want from Twitter is "view this user's tweets without showing their retweets"
Note that this isn't the same thing as turning off someone's retweets - I want to go to the profile of someone I don't even follow and see what they actually say, not just a stream of stuff they have retweeted