richardmavis · 2022-10-27 04:33
Here's a little derived mode that makes using emacs as a MySQL client a little more developer-friendly: [https://git.sr.ht/\~rfm/dbcnx-mode/tree/master](https://git.sr.ht/~rfm/dbcnx-mode/tree/master)
Essentially, you name SQL files according to the keys in your \`sql-connection-alist\`, and with a \`dbcnx\` extension. The mode adds one keybinding: \`C-c C-l\`, which connects using the credentials associated with the filename/alist key, leaving you with one buffer containing queries you want to run and another in which to run them and see the results.
For a bit more detail: [http://richardmavis.info/using-emacs-as-a-mysql-client](http://richardmavis.info/using-emacs-as-a-mysql-client)
yordanm · 2022-10-27 07:27
That's great! How hard it is to make that mode support also SQLite and Postgres as I guess they're widely more used?
rhabarba · 2022-10-27 08:28
sql-mode [already does that.](https://www.emacswiki.org/emacs/SqlMode)
deaddyfreddy · 2022-10-27 09:20
there's also https://github.com/kostafey/ejc-sql it requires clojure/cider, though
7890yuiop · 2022-10-27 12:15
Do you see where it says `sql-product 'mysql` in the linked code? Use whichever product you want instead of that.
(I haven't tested the code, but it's hard to imagine that it's actually MySQL specific in any way.)
richardmavis · 2022-10-27 13:42
Yup, connecting to other databases should be as easy as this 👍
sebhoagie · 2022-10-27 14:49
Shameless plug: I made a small Python-based command line client that connects via ODBC. It has a companion Emacs package that adds the tool as a new `sql-product`.
Disadvantage: it's not the fastest.
Advantages: one tool to connect to all databases, and support to have pre-canned queries.
https://github.com/sebasmonia/datum
grtcdr · 2022-10-28 00:23
I wouldn't suggest ejc-sql at the moment as it simply fails to connect to various kinds of database systems as I and others have reported in [this issue](https://github.com/kostafey/ejc-sql/issues/168).