Slight off-topic, but getting organized was a lifelong struggle for me (I was the person who had a five-foot high stack of unorganized papers and crap in their locker in middle and high school), and org-mode is the only system that broke me out of that cycle. It has genuinely changed my life. It's not for everyone, but if you've been unsatisfied with everything else and keep jumping from system to system, it's worth a try. (Especially now that you can get Claude to just explain the basics of Emacs configuration to you, which wasn't the case when I started.)
Use org-babel to execute the queries, from my “sql-queries.org” file.
Overwrite results into a /tmp file, also an org-mode file, with latest query results (call it anything — “query-result.org”).
Make psql spit out org-formatted tables for extra oomph.
Keep that results file open in another buffer (or frame on a big screen, if the table is wide).
Let Emacs auto-refresh the buffer, when it detects the file has changed.
Et voila! L’établi SQL du pauvre.
Screenshot + sample code in the gist below (a `.org` file, as befits this topic :)
I used Org Mode for all mandatory assignments [0] when I was a student, it worked super well and I could create well formatted LaTeX documents/PDFs from it as well. The supervisors were very impressed that I did my assignment in LaTeX, and I could never be bothered to correct them :-)
Kudos to you, my biggest regret nowadays was not learning how to use orgmode (and org-roam) in college. As long as you set up a proper environment and have an org-publish config you barely need to bother with verbose LaTeX documents.
Very much this. In fact, I had made a note about earning "professor points", in my (giant) blog post [0] describing my org-mode use...
6. Professor Points: I also get intermediate tex output for free,
which I don't need, but may please you if you are a professor
(or said professor's hopelessly sleep derived grad students).
---
[0] Discussed here recently:
Why and How I use “Org Mode” for my writing and more (2022) (evalapply.org)
217 points by sebg | 6 months ago | 64 comments
ah ... hahaahhh ... quite possibly, I was sleep, ah, derived at the time of finishing it up ... i shall let the typo remain, to vex yet another eagle-eyed reader
I used a similar setup a long while ago and wanted a way to connect to databases easily. So I wrote some code to parse the MySQL and Postres config files to extract database info in Emacs: https://stackoverflow.com/a/46114944
Emacs with databases without org would be interessing. I now there is sql-mode which supposedly works to connect with an inferior process but a tuorial about that would be nice
Slight off-topic, but getting organized was a lifelong struggle for me (I was the person who had a five-foot high stack of unorganized papers and crap in their locker in middle and high school), and org-mode is the only system that broke me out of that cycle. It has genuinely changed my life. It's not for everyone, but if you've been unsatisfied with everything else and keep jumping from system to system, it's worth a try. (Especially now that you can get Claude to just explain the basics of Emacs configuration to you, which wasn't the case when I started.)
You can also combine this with TRAMP to work on databases you can't directly access from your local machine. E.g.:
You can also set a `.pgpass` in your `$HOME` or point another path to a `PGPASSFILE` envar, so postgresql credentials don't leak to main org file.
https://www.postgresql.org/docs/current/libpq-pgpass.html
My “Poor Man’s SQL Workbench” trick is to…
Et voila! L’établi SQL du pauvre.Screenshot + sample code in the gist below (a `.org` file, as befits this topic :)
https://gist.github.com/adityaathalye/a6004acd34c683bcc806b2...
I used Org Mode for all mandatory assignments [0] when I was a student, it worked super well and I could create well formatted LaTeX documents/PDFs from it as well. The supervisors were very impressed that I did my assignment in LaTeX, and I could never be bothered to correct them :-)
[0]: https://gist.github.com/sondr3/ae4eda2816cfeda7b8597ce1c48d0..., best viewed as the raw file for all the details
Kudos to you, my biggest regret nowadays was not learning how to use orgmode (and org-roam) in college. As long as you set up a proper environment and have an org-publish config you barely need to bother with verbose LaTeX documents.
https://www.orgroam.com/
Very much this. In fact, I had made a note about earning "professor points", in my (giant) blog post [0] describing my org-mode use...
---[0] Discussed here recently:
https://news.ycombinator.com/item?id=43157672^derived^deprived
ah ... hahaahhh ... quite possibly, I was sleep, ah, derived at the time of finishing it up ... i shall let the typo remain, to vex yet another eagle-eyed reader
I used a similar setup a long while ago and wanted a way to connect to databases easily. So I wrote some code to parse the MySQL and Postres config files to extract database info in Emacs: https://stackoverflow.com/a/46114944
Emacs with databases without org would be interessing. I now there is sql-mode which supposedly works to connect with an inferior process but a tuorial about that would be nice
You may be interested in PGmacs, a viewing/editing interface for PostgreSQL.
https://github.com/emarsden/pgmacs
(self-plug)
I second that and would be interested in the sqlite-mode version of the tutorial.