Questions tagged [sql]

31 questions
18
votes
4 answers

Automatically formatting SQL code

There are some general well-known coding standards and styles for SQL (e.g. capitalizing reserved words, placing main keywords in different lines, etc.). Does Emacs come with any modes for this, or are there any packages for formatting SQL to make…
Amelio Vazquez-Reina
  • 5,157
  • 4
  • 32
  • 47
10
votes
2 answers

org-babel and remote sql commands

I'm using org-babel to do litterate programming and I find it very convenient. I am able to execute shell commands on remote hosts, and local database commands with the postgres client. To open a file as postgres user, it would look for example like…
KookieMonster
  • 387
  • 4
  • 10
8
votes
2 answers

less psql, more emacs

I was listening to this song today - https://www.youtube.com/watch?v=ajy71xw351E Don't Wanna Leave You Now and I realized how much I don't want to leave emacs. I often do this after backgrounding (C-z) emacs, psql datababase_name select id from…
american-ninja-warrior
  • 3,773
  • 2
  • 21
  • 40
6
votes
2 answers

How to copy org-table to postgresql database?

With sqlite one can easily populate a table in a database via a org-table like so: [EDIT](using only one sqlite-scr-block with org-table variable parameter)[/EDIT] #+NAME: A | val1 | val2 | |------+------| | 2 | 16 | | 4 | 25 | | 10 | …
kai-dj
  • 427
  • 2
  • 15
5
votes
2 answers

How to indent SQL code just 4 spaces, without alignment &c?

SQL mode has some cool stuff set up for indenting with aligned keywords and such. Normally, I'd think it was cool. The problem is that at my new job, the people who wrote our mountains of sql did not have this set up, and just indented sql 4…
user3113723
  • 181
  • 6
4
votes
1 answer

can emacs be taught what tables exist in a sql database

In emacs (in whatever mode you recommend for accessing a Postgres database) is it possible to type select * from foo_ and somehow get autocomplete/help as to what tables are available in the database ( tables that start with foo_ ) I would…
american-ninja-warrior
  • 3,773
  • 2
  • 21
  • 40
4
votes
2 answers

How to change the indentation of major mode (SQL-mode)?

Configuration: Emacs 25.0.50 on Ubuntu 15.04. How to produce? Do emacs -Q, then M-x sql-mode. Paste the following in the buffer: SELECT SUM(T01.foobar) FROM db_foo.bar T01 WHERE T01.fooID = 1 AND T01.barID = 2 AND T01.foo IS NOT NULL' When…
ReneFroger
  • 3,855
  • 22
  • 63
3
votes
1 answer

Aggressive SQL indentation in emacs

I want an emacs SQL indentation function with the following properties: Upcase { select, from, as, where, group by, order by, asc, desc, and, or }. - EDIT: there are sqlup-mode.el and sql-upcase.el which both address this part of the…
Realraptor
  • 1,253
  • 6
  • 17
3
votes
1 answer

What's the proper new-style form for passing header args to all sql code blocks?

I guess I've been out of the loop for a while. I used to have this at the end of my org-mode SQL files: #+PROPERTY: engine mysql #+PROPERTY: dbhost xx.xx.xx.xx #+PROPERTY: dbuser xxxxxx #+PROPERTY: dbpassword xxxxxxxxx #+PROPERTY: database…
GaryO
  • 476
  • 2
  • 16
2
votes
3 answers

How can I query an existing SQLite database from elisp, that is, non-interactively?

There are multiple questions with "sqlite" in the title, but they all want to run SQL queries interactively, which sql-mode does. What I want is the following: I have a pre-existing SQLite database whose format I know. This database is maintained…
2
votes
0 answers

Reference env variable in org babel source block headers

I am setting up an org-mode document to connect to a postgreSQL database and execute+show the results of some queries. I don't want the database password visible in the org document (regardless of whether the document is exported: I want to be able…
dlid
  • 121
  • 5
2
votes
1 answer

Storing Database Authentication Details Securely

(Note: I would normally use gpg versions of these files but for debugging I've scrapped gpg until I can get it working without encrypting!) I'd like to store my username/password credentials securely for use with Emacs for database logins - using…
Phil
  • 533
  • 4
  • 17
2
votes
2 answers

Can syntax parsing recognize the SQL '' (escape apostrophe/single quote) construct within SQL strings?

I am trying to enhance SQL mode such that editing of files of SQL code becomes more convenient, especially as far as jumping around is concerned (e.g. things like sql-goto-end-of-string etc.). I have found syntax parsing to be very useful in that,…
fsavigny
  • 33
  • 3
2
votes
1 answer

Set the password for sql-postgres

I have a question regarding connecting to a sql database programmatically. Ideally I would like to have a function with similar functionality to the sql-postgres but instead of interactively prompting me for each part of the connection string, I…
Zac Romero
  • 175
  • 5
2
votes
1 answer

Is possible to execute sql query direct in org mode?

windows 10, emacs 26.1 I know that in org mode I can insert source code and execute them. Nice. But what about sql: Here in my.org file: #+name: some_query #+BEGIN_SRC sql SELECT * FROM invoice WHERE id IN (1,2,3) #+END_SRC Is it…
a_subscriber
  • 3,854
  • 1
  • 17
  • 47
1
2 3