QueenOfHatred · 2022-04-23 18:12
So.. I recently started SQL stuff at uni, to be specific, postgresql.
And so, I am not too sure what is the proper workflow, or what libraries are best
Right now I just like... Have buffer with file, buffer with psql, write query in psql, and if it works, copy paste into the buffer.
But I feel that is quite... inefficient in a way.
So I am curious how it should be done #\_#?
brurucy · 2022-04-23 18:44
Just use LSP with SQL.
hvd617 · 2022-04-23 18:45
Have you look into org mode with sql? https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-sql.html
ieure · 2022-04-23 19:02
Emacs has had [built-in support for SQL](https://www.emacswiki.org/emacs/SqlMode) for decades. Run `sql-postgres` and it'll prompt you for the connection params; you can also configure `sql-connection-alist` with presets and use `sql-connect`.
With a `sql-mode` buffer, you can use `C-c C-b` to send its contents to the inferior SQL.
The Org-Babel support is also really nice, since you can build and execute queries, then use proper programming languages to do stuff with the output, sort of like a Jupyter notebook.
worthless-trash · 2022-04-24 05:12
Came here to suggest exactly this. It is good for learning queries and for being able to refer back to in the future.
You can even mix different org-babel types into the same document for when you use use the shell for commands or python or whatever.
neo2551 · 2022-04-24 05:37
I use Clojure and write my queries using honeySQL, save my sanity from text based language vs data structures.