With a little side of applesauce...

Tuesday, November 9, 2010

EMACS - enhancements for SQL-Mode

I found these great Elisp examples for enhancing SQL-Mode:

"Better Buffer Naming" - "*SQL: dbhost/dbname*"
"Support for TCP Ports" - allows for you to specify multiple TCP ports on a single host.
"Support for Preset Connections" - like bookmarks, only for DB connections :)

My only real changes were to:
1. change pool-a/pool-b to pool-myhost_dbname. This gives me a quick visual to see to which host and db I will be connecting (grammar? :P ).
2. use sql-product 'postgres for PostgreSQL.
(setq sql-connection-alist
(sql-product 'postgres)
(sql-server "myhost.example.org")
(sql-user "myuser")
(sql-password "mypass")
(sql-database "dbname")
(sql-port 5432))))

(defun sql-pool-myhost_dbname ()
(sql-connect-preset 'pool-myhost_dbname))

Here is the great article:

No comments: