Fork me on GitHub
#emacs
<
2023-02-07
>
Mario Giampietri11:02:58

Is anyone using Emacs for SQL integration? Meaning: writing/running queries for exploratory purposes (as you would do with JetBrains DataGrip, or MS SQL client or similar). Brownie points for sharing your thoughts on the setup experience, if in your case it was smooth, or if it was the standard Emacs discovery experience (AKA at least 2 dreadful weeks of painful yak shaving ๐Ÿค“). Thanks ๐Ÿ™‚

upvote 2
pavlosmelissinos12:02:14

I'm also interested in this but Clojure REPL + next-jdbc + Clerk or Portal with emacs UI might be more ergonomic than anything emacs has to offer

๐Ÿ‘ 2
djm13:02:29

On the setup side, thereโ€™s some helpful stuff here on setting up sql-connection-alist: https://dev.to/viglioni/emacs-as-sql-client-with-lsp-143l I have my own version of that, for use with sql-connect (I donโ€™t use the lsp stuff).

๐Ÿ‘€ 4
๐Ÿ‘Œ 2
Zed14:02:24

What I do is run sql-postgres in the buffer I'm editing my SQL in, which connects me to my database with a buffer running psql, and then using C-c C-c on a SQL statement evaluates it in the psql buffer. I use this for development, when writing SQL queries. I don't recall setting it up being difficult. Looking at my config, there's a value for sql-postgres-options and some customizing of its prompt regexps that I probably copied and pasted from somewhere

๐Ÿ‘Œ 2
Ben Sless16:02:06

I'm doing it with org and babel, I can leave comments and documentation around that way, and data comes back as nicely formated tables

๐Ÿ‘Œ 2
Mario Giampietri17:02:52

I'm going to play with the proposed approaches one of these days thanks, everyone ๐Ÿ™‡

Mario Giampietri18:02:07

I ended up trying this today and yes, basic setup / connection / integration is smooth (as long as you have cli clients and drivers backing you up). Unfortunately the data I'm querying includes massive unstructured data which floods the screen, for these cases other GUIs have an edge. Thanks anyway though

pavlosmelissinos18:02:07

Is this for a Clojure project @U017QU43430?

Mario Giampietri18:02:14

today contingency was more plain old sql. I have in my radar/wishlist to try and bring some Clojure treat (such as Portal you mentioned, but also HoneySQL) to make the query-ing experience more enjoyable, it will be for another round ๐Ÿ™‚

๐Ÿ‘ 2
pavlosmelissinos18:02:21

> unstructured data which floods the screen, for these cases other GUIs have an edge This is true, I personally haven't been able to use emacs/org mode for SQL effectively for the same reason but I want to get rid of external GUI programs eventually. They're great for visualization but that's it, they're not a live system.

Mario Giampietri19:02:36

I don't feel strongly about using Emacs at all costs for everything. On this front, also many free options (including VS Code plugin) don't get anywhere close to the smoothness of the paid ones (thinking of DataGrip). I'm going to try also GToolkit, at least for data iterations. It's not Emacs but still a respectable, somewhat lispic option worth exploring ๐Ÿ˜„ https://gtoolkit.com/usecases/iterative-data-exploration

๐Ÿ‘ 2
vemv20:02:08

anyone (successfully) browsing Github Issues from Emacs? I'm thinking of reading the whole conversations, including pictures, replies, code snippets, being able to follow links I'm not sure if I'd want to read the content as raw/ish markdown or rendered prettily (italics not _italics_ etc)

vemv20:02:55

this sounds like an @U0G75ARHC type of question :)

ag20:02:44

issues, no. But individual files, yes.

vemv20:02:35

Interesting! But probably a different use case. I was seeking browsing GH issues because on a good project, it's the only thing that would hold me back from closing Chrome entirely, which would increase my focus.

ag20:02:32

You don't use forge?

ag20:02:15

I use gh-notiify, forge and code-review

vemv20:02:56

I mostly don't use magit or a lot of Git stuff. Maybe some handrolled helpers (my favorite one opens each file from git status in a buffer - great for coming back to a context)

practicalli-johnny20:02:14

Any reason not to use Magit Forge for issues? I use Magit Forge for GitHub issues and pull requests https://practical.li/spacemacs/source-control/magit/forge/issues/

โ˜๏ธ 2
vemv20:02:30

> Any reason not to use Magit Forge for issues? I'm just learning about it in this thread :) mind to show how a specific issue is rendered? (also, the existing pictures are broken in your link)

practicalli-johnny20:02:14

I'm migrating the images at the moment but will try remember to add an image for issues

practicalli 2
vemv20:02:31

Cheers. I'll check out https://github.com/magit/forge carefully - wondering about its markdown and image capabilities.

Drew Verlee23:02:00

Would anyone else benefit from a cider eval-and-replace-sexp-*pretty-printed option?* If so, ill add it to my list of things i need to figure out how to build then advertise it, or try to get it added to existing tools. Alternatively if there is a way to take a clojure structure and turn it into a pretty pretty printed one i would love to know about it? e.g

{:name "drew :age "bee keeping age"} 

pp ->

{:name "drew" 
 :age "bee keeping age"}

โž• 6
dpsutton23:02:25

there is shell-command-on-region bound to M-| by default for me. If you give it a prefix argument it will replace the region. So I highlight some map, C-u M-| jet and it works for me

โœ… 2
๐Ÿ’ก 2
dpsutton23:02:13

{0 1, 20 21, 24 25, 46 47, 4 5, 48 49, 32 33, 40 41, 22 23, 36 37, 44 45, 6 7, 28 29, 34 35, 12 13, 2 3, 14 15, 26 27, 16 17, 38 39, 30 31, 10 11, 18 19, 42 43, 8 9} becomes

{0 1,
 20 21,
 24 25,
 46 47,
 4 5,
 48 49,
 32 33,
 40 41,
 22 23,
 36 37,
 44 45,
 6 7,
 28 29,
 34 35,
 12 13,
 2 3,
 14 15,
 26 27,
 16 17,
 38 39,
 30 31,
 10 11,
 18 19,
 42 43,
 8 9}

Drew Verlee00:02:04

that's a great idea. Thanks! You should make a video about all the small stuff you do to save you time ๐Ÿ™‚ .

dpsutton00:02:25

i only recently learned that one

dpsutton00:02:39

itโ€™s obvious with the tools that emacs provides. but i donโ€™t think about those often sometimes

dpsutton00:02:53

and pick things up from blogs or things in here. i love tricks and tips in here

Drew Verlee00:02:00

honestly, i always just pretty print and then remove the comment part lol

dakra08:02:05

If you use cider there's also an interactive cider-format-edn-region function which does the same.

๐ŸŽ‰ 2