So, Emacs has a built-in interactive SQL mode (M-x sql-mysql / postgres / sqlite). This mode opens a SQL shell similar to what you would see in a terminal. From there, you can do your selects, inserts, updates, etc.
You can also send strings from a different buffer to your SQL shell buffer.
Now in Emacs you can very easily evaluate Lisp code to define functions, redefine functions, and execute arbitrary expressions. You can also wrap your SQL expressions inside of Lisp code. By doing so, you can take advantage of Emacs's built-in Lisp evaluation tools to interact with your SQL database.
So instead of opening a shell in your terminal, selecting a database, and writing select statements to inspect your DB, you can instead...
In Emacs, create a file called something like "sql-notebook.el". Inside that file you write Lisp expressions to execute SQL queries. To execute those queries, you move the cursor over it and just run the command `eval-last-expr` (I have this bound to Ctrl-c Ctrl-c). The results of the evaluated expressions appear in your interactive SQL buffer.
The obvious advantage of this is that you end up creating a library of often-used queries which are very convenient to execute simply by moving the cursor over the query and hitting Ctrl-c twice.
You also retain a history of these queries by virtue of them existing in a plain file, as opposed to ephemeral shell history.
hey thats pretty cool, I will try to see how that works, I didn't know it. But it sounds like a lot of work to set it up. I wanted to make something faster
It's not a lot of work, but it takes a little bit of existing Elisp knowledge. You can still evaluate plain SQL code in a buffer (sql-mode) and get most of the benefits I described, you just won't get the convenience of evaluating Lisp forms.
This might be a great tool, but the demo is horrible. The gif slowly builds up to something interesting, showing the setup of the tool. But then when it gets to showing the output, the gif resets back to the beginning. What does the tools actually provide?
Instead of a gif, please just paste that output into code fences in the README file.
While working on other projects, I found myself always having to connect and use SELECT * to see dummy entries or new users. I favored the CLI for monitoring my database entries, especially because I was testing and just adding dummy users + our first normal users in projects. So it became a bit tiring always having to connect to postgres, mysql and give select * queries from the CLI.
This tool appeals to me as someone who is already familiar to pgcli, psql, mysql, etc. Typing every time SELECT * FROM… annoys me, too.
I’d prefer to already evaluate the tool in the first or second paragraph. If you could move the readme section with the most eye opening and time saving commands right after the video, that would be great.
I started this with the focus being on speed set it up run thencommand and see the output. Harlequin seems to have a bit more hassle. We d also like to add a gui at some point if the user wants to open it on browser
So, Emacs has a built-in interactive SQL mode (M-x sql-mysql / postgres / sqlite). This mode opens a SQL shell similar to what you would see in a terminal. From there, you can do your selects, inserts, updates, etc.
You can also send strings from a different buffer to your SQL shell buffer.
Now in Emacs you can very easily evaluate Lisp code to define functions, redefine functions, and execute arbitrary expressions. You can also wrap your SQL expressions inside of Lisp code. By doing so, you can take advantage of Emacs's built-in Lisp evaluation tools to interact with your SQL database.
So instead of opening a shell in your terminal, selecting a database, and writing select statements to inspect your DB, you can instead...
In Emacs, create a file called something like "sql-notebook.el". Inside that file you write Lisp expressions to execute SQL queries. To execute those queries, you move the cursor over it and just run the command `eval-last-expr` (I have this bound to Ctrl-c Ctrl-c). The results of the evaluated expressions appear in your interactive SQL buffer.
The obvious advantage of this is that you end up creating a library of often-used queries which are very convenient to execute simply by moving the cursor over the query and hitting Ctrl-c twice.
You also retain a history of these queries by virtue of them existing in a plain file, as opposed to ephemeral shell history.