;;------------------------------------------------------------------------ ;; ;; functions to connect interactiv to a DB Server ;; ;; $Id: dbconnect.el,v 1.3 2004/12/14 21:47:07 jg Exp $ ;; ;; Keywords: db-connect, SQL, SQLi ;; Author: Jens Giessmann ;; e-mail: jg@handcode.de ;; ;; This file is an add-on for XEmacs or GNU Emacs (not tested with the latter). ;; ;; It is free software; you can redistribute it and/or modify it ;; under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 2, or (at your option) ;; any later version. ;; ;; It is distributed in the hope that it will be useful, but ;; WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License ;; along with your copy of Emacs; see the file COPYING. If not, write ;; to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, ;; Boston, MA 02111-1307, USA. ;; ;; This file provide 3 little functions for interactiv db-sessions ;; with (X)Emacs to MySQL, postgreSQL and Oracle. You will need the ;; appropriate client installed for each DB. ;; ;; Each function will split your screen in 2 windows. The upper one ;; is the "logfile" where you can write your SQL-querys as in the ;; db-client. ;; You can send SQL statements to the SQLi buffer (the lower window) ;; using: ;; ;; C-c C-b sql-send-buffer ;; C-c C-c sql-send-paragraph ;; C-c C-r sql-send-region ;; ;; You can customize the path to the SQL-Log files for the 3 DBs ;; separately ;; ;;------------------------------------------------------------------------ (provide 'dbconnect) (require 'custom) ;;------------------------------------------------------------------------ ;; Customize ;;------------------------------------------------------------------------ (defgroup xdb-connect nil "interactiv db-sessions" :prefix "xdb-" :group 'local) (defcustom xdb-mysql-sqli-file "/tmp/MySQL-log.sql" "Default SQLi file for mysql-sessions" :type 'string :group 'xdb-connect) (defcustom xdb-oracle-sqli-file "/tmp/ORA-log.sql" "Default SQLi file for oracle-sessions" :type 'string :group 'xdb-connect) (defcustom xdb-psql-sqli-file "/tmp/PSQL-log.sql" "Default SQLi file for postgresql-sessions" :type 'string :group 'xdb-connect) ;;------------------------------------------------------------------------ ;; functions ;;------------------------------------------------------------------------ (defun myconnect () "connect to a MySQL DB server with interactiv sql-Buffer" (interactive) (sql-mysql) (add-to-list 'auto-mode-alist '("\\.sql\\'" . sql-mode)) (find-file-other-window xdb-mysql-sqli-file) (sql-set-sqli-buffer)) (defun oraconnect () "connect to a Oracle DB server with interactiv sql-Buffer" (interactive) (sql-oracle) (add-to-list 'auto-mode-alist '("\\.sql\\'" . sql-mode)) (find-file-other-window xdb-oracle-sqli-file) (sql-set-sqli-buffer)) (defun psqlconnect () "connect to a PostgreSQL DB server with interactiv sql-Buffer" (interactive) (sql-postgres) (add-to-list 'auto-mode-alist '("\\.sql\\'" . sql-mode)) (find-file-other-window xdb-psql-sqli-file) (sql-set-sqli-buffer)) ;;------------------------------------------------------------------------ ;; END dbconnect.el