emacs

Shantanu Kumar 2024-12-06T13:37:07.758549Z

Hi, has anyone encountered this error setting up emacs with (package-initialize) and installing use-package?

Failed to verify signature archive-contents.sig:
No public key for 645357D2883A0966 created at 2024-12-06T15:35:02+0530 using EDDSA
Command output:
gpg: Signature made Friday 06 December 2024 03:35:02 PM IST
gpg:                using EDDSA key 0327BE68D64D9A1A66859F15645357D2883A0966
gpg: Can't check signature: No public key
I tried running gpg --homedir ~/.emacs.d/elpa/gnupg --receive-keys 0327BE68D64D9A1A66859F15645357D2883A0966 but it returns gpg: keyserver receive failed: No data and doesn't help.

Shantanu Kumar 2024-12-06T13:39:39.298099Z

My initialization looks like this:

(setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3")
(package-initialize)
(package-refresh-contents)

(unless (package-installed-p 'use-package)
  (package-refresh-contents)
  (package-install 'use-package))
(require 'use-package)
(setq use-package-verbose t)
(setq-default use-package-always-ensure t)

oyakushev 2024-12-06T13:47:51.257349Z

I've seen gpg errors quite a few times, but it is usually fixes by removing some caches, don't remember exactly.

andy 2024-12-06T14:21:54.171569Z

when I've hit this, I had to • M-: (setq package-check-signature nil)M-x package-refresh-contentsM-: (setq package-check-signature 'allow-unsigned)

Shantanu Kumar 2024-12-06T15:19:15.301219Z

@luandy64 That helped, thanks! @alexyakushev I was trying to do a fresh setup, so I hardly had any cache.

Adam Mertzenich 2024-12-06T22:32:46.365799Z

EmacsConf 2024 starts tomorrow, what talks are you interested in? https://emacsconf.org/2024/talks/

Adam Mertzenich 2024-12-06T22:35:25.969579Z

I'm particularly looking forward to https://emacsconf.org/2024/talks/org-update and https://emacsconf.org/2024/talks/shell.

Zeniten 2024-12-06T23:03:02.120629Z

I'm looking forward to the former as well, and the Rust talk: https://emacsconf.org/2024/talks/rust. 😄

Drew Verlee 2024-12-06T00:50:24.643669Z

How do you work with sql and postgres in emacs? I just spent like 2 hours trying to get sq-ls installed so it worked with my spacemacs sql layer setup and it's not working (i can share details but basically emacs keeps re-prompting me to restart sql-ls no matter what i do or install). I'm about ready to just default to using pgadmin anytime I have to touch a sql file. I'm open to suggestions or sql life advice.

2024-12-11T11:23:59.576759Z

ah, proper org-babel work. nice

jumar 2024-12-07T08:22:22.000669Z

I still use IntelliJ for connecting to databases.

👍 1
daniel.vieira 2024-12-07T15:46:45.790569Z

@drewverlee I used to use vim-dadbod https://github.com/tpope/vim-dadbod. When I migrated to emacs I started looking and found ejc-sql and started using it. I haven't explored much of other options though. But when I need more involved things I use dbeaver. I mean when I need to explore pg functions, diagrams etc.

👍 1
Drew Verlee 2024-12-07T15:53:49.542779Z

Thanks for the insights. I'm well armed with a couple good choices now.

👍 1
Macroz 2024-12-06T08:05:46.844919Z

M-x sql-postgres ... enter connections details ... enter low level SQL Everything else from Clojure using same stuff as in the program I'm developing.

👍 1
1
2024-12-06T08:40:35.534019Z

what is sq-ls?

2024-12-06T08:41:36.462849Z

I'm reasonably happy using sql-connection-alist, ~/.pgpass, and org-babel to poke at things, but that might not be enough for all

Ed 2024-12-06T10:20:49.865329Z

after doing M-x sql-postgres and connecting, I then do C-c C-c in an sql-mode buffer to send that sql to the inferior process and run it - so the workflow is a lot like writing clojure code in a '(comment ,,, )' block. Sometimes I've had to run sql-set-sqli-buffer in the sql buffer to wire it to the right inferior process, but I think that's only when I've been connecting to multiple dbs.

Stig Brautaset 2024-12-06T10:20:51.844539Z

sql-postgres is where it's at for me.

Stig Brautaset 2024-12-06T10:21:51.770969Z

The only annoyance is I've not figured out how to connect to two different postgres DBs so I can go back and forth between dev / production replica to compare query plans.

Stig Brautaset 2024-12-06T10:27:58.215949Z

(FWIW put connection details for projects in .dir-locals.el )

Ed 2024-12-06T11:02:34.506239Z

you can connect to multiple dbs by running C-u M-x sql-postgres. In the sql buffer you need to clear the local variable sql-buffer then use sql-set-sqli-buffer to select the one you want to send sql to. I usually put -- (setq-local sql-buffer nil) in the sql file and eval it with C-x C-e and then run sql-set-sqli-buffer-generally from the target sql buffer to update the buffers I've cleared. You can check where the sql will go when you run it with C-c C-z to show the target sql buffer. It's very easy to mess up, but I don't do it a lot, so I've never tried to fix it 😉

2
Durant Schoon 2024-12-06T11:49:17.588799Z

This might also be of interest to everyone here (happening Sunday): https://emacsconf.org/2024/talks/pgmacs/

🆒 3
Durant Schoon 2024-12-06T11:54:44.326889Z

^ "show me the code" https://github.com/emarsden/pgmacs

Ed 2024-12-06T11:59:08.004959Z

The advantage of sql inferior buffers for me is the number of different dbs supported. I've used it to work with mysql, pg, oracle, informix and others. Although, in recent years pgsql has become the default choice. I'd not heard of pgmacs before. It looks pretty cool. I might have to add it to the list of things to check out 😉. Thanks

👍 1
feng 2024-12-06T13:08:09.088739Z

I may suggestion you to access postgredb from emacs by repl of clojure with honeysql DSL, as it can do all what you are going to query and more step you can transform your data to any format using the tools clojure and libs offer

🙏 1
2024-12-06T13:13:22.807749Z

I do both. Depends on what I'm doing. I do some honeysql and clerk as well. I like it

💯 1
djm 2024-12-06T14:15:36.170229Z

I have something similar to the "Macros make your life easier" section here: https://dev.to/viglioni/emacs-as-sql-client-with-lsp-143l (and use sql-connect)

Drew Verlee 2024-12-06T18:50:41.189859Z

thanks, sql-postgres seems very useful.

Drew Verlee 2024-12-06T18:55:19.462999Z

> what is sql-ls? It's something my emacs setup tells me "restart" when ever i open a sql file. Likely beacuse i have the spacemacs https://www.spacemacs.org/layers/+lang/sql/README.html. I think it's talking about the lsp support, and so it should talking about https://github.com/sqls-server/sqls. but i installed that through the readme instructions and did a lsp-install server sql through emacs.

daniel.vieira 2024-12-06T21:50:41.158279Z

I use this https://github.com/kostafey/ejc-sql

👍 2
Drew Verlee 2024-12-07T02:21:12.641369Z

fwiw i fixed my sqls issue by removing the one emacs installs and installing it myself via npm.

Drew Verlee 2024-12-07T02:22:07.695849Z

maybe it was happening because my root emacs directory isn't in the stereotypical place or something.

Drew Verlee 2024-12-07T02:32:13.009269Z

@danielhvs70 what else have you tried besides ejc-sql? Why did you end up there?

Drew Verlee 2024-12-14T06:27:50.932129Z

thanks again ag, yeah, I can see how that would be useful. Ill defiantly keep it in the back of my mind.

Drew Verlee 2024-12-06T05:39:00.699589Z

i'm going to play a bit with db beaver, emacs, datagrip and what-ever-intellij does, and see if any of them sparks joy. So far datagrip has the best quick schema uml diagram viewer. All the UI's seem "ok". Overall, it's hard to judge a tool without a problem to hand.

ag 2024-12-10T03:46:44.854969Z

I just use org-mode src blocks like this:

#+begin_src sql :engine postgresql :dbhost localhost :dbport 5003 :database connections :dbuser postgres :dbpassword password
select * from platform_integration_properties where platform_integration_id = 16;
#+end_src

👀 1
ag 2024-12-10T03:48:19.646179Z

what's great about org-mode source blocks that you can "pipe" them one into another. You can run sql, pass it into clojure block (where you can do some data manipulation), then pass the results of that calculation into yet another block, and so on.

2024-12-10T08:37:39.496799Z

@ag if you set up sql-connection-alist, ~/.pgpass you don't need to put the password and other things in the org-mode doc (which may or may not be a security issue for you)

👍 2
🖖 2
Drew Verlee 2024-12-10T23:12:28.026159Z

Thanks Ag, yeah, org mode is probably one of the best go-to starting tools around.

ag 2024-12-11T00:00:50.752769Z

Here's a basic example of passing data between org-mode source blocks. • Fist thing queries the db • Because it's a named block, the var can be referred by the name in the next one • The second block takes that tabular data and turns into a json thing • The third block, using 'jq', formats it nicely • wrap src json at the last one to push it into a syntax-highlighted json block I mean this is pure fabrication, if the goal is to get json, you don't need to do all that, because with sqlite you can simply add .mode at the top of the block, like this:

#+begin_src sqlite :db ~/.emacs.d/.local/org-roam.db
.mode json
SELECT * FROM links LIMIT 1;
#+end_src
But let's imagine we're dealing with a different kind of sql db. what's crazy is that you can even use elisp vars and function results in :vars like for example in this request where token gets grabbed from an env var:
#+begin_src http :pretty :var token=(shell-command-to-string "echo $MYTOKEN") 
GET 
Content-Type: application/json
Authorization: Bearer ${token}
#+end_src
The limitation I can think of is if you're returning thousands of rows, of course, in that case, Emacs will struggle to render them - things may get sluggish. But guess what? You can always dump the results into a file, just add :results output file :file ~/foo.json Hope you find this helpful.

❤️ 2