3 ms·
If you haven't yet; set the following environment variables in your shell: export PAGER='less -S' export EDITOR='emacs -nw' #or a lesser editor if you
by olefoo 13y ago
If you haven't yet; set the following environment variables in your shell:
export PAGER='less -S'
export EDITOR='emacs -nw' #or a lesser editor if you prefer
That way you'll get result sets without linewraps and your queries will be edited in the non-default editor, which is `vi` in most distributions.
- cbsmith 13y agoMight as well go whole hog with Emacs' SQL-mode and/or pg.el
- olefoo 13y agoI like sql-mode but I also like doing things in the terminal. Using sql-mode in emacs is for developing queries, but psql is what I use to talk to a database of any consequence. A large part of that is so that I know what context I'm in. Slightly more cautious and consequence oriented when it's the production database with ten million rows of PII and less so when I'm programming.
- cbsmith 13y agoSQL-mode is a wrapper around psql that makes the psql tool a bit more human friendly. You can always add a buffer name / theme for production to avoid confusion. General rule of thumb: caution for production should take the form of a more careful code release process (i.e., you release scripts that talk to the database, not use psql directly). Executing interactive queries isn't for prod.
- olefoo 13y agoOh dear; I fear you have gotten the wrong idea. I spend most of my time in emacs doing things in python, sql or what have you. Usually the only time I talk to a production database directly is when it's already in trouble. And yes; one's migrations and DDL etc. should all be tested before being rolled out to production; apparently that is not an assumption people make around here.
- cbsmith 13y agoApologies. I definitely got the wrong idea. Generally no one does ad hoc queries to prod, even when in trouble. It's all, "sync to offline DB, check it out there".