Compare commits
2 commits
mysql-supp
...
main
Author | SHA1 | Date | |
---|---|---|---|
44c596acca | |||
3e76f589e8 |
6 changed files with 2208 additions and 154 deletions
|
@ -1121,7 +1121,7 @@ identifier."
|
|||
(defun pls-adjust-case-interactive (arg)
|
||||
(interactive "P")
|
||||
(if pls-auto-case
|
||||
(let ((lastk last-command-char))
|
||||
(let ((lastk last-command-event))
|
||||
(cond ((or (eq lastk ?\n)
|
||||
(eq lastk ?\r))
|
||||
;; horrible kludge
|
||||
|
|
2198
contrib/plsql-mode.el
Normal file
2198
contrib/plsql-mode.el
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,66 +0,0 @@
|
|||
|
||||
* Processes
|
||||
** Startup
|
||||
- =(enode project)=
|
||||
+ =(enode-available-projects)=
|
||||
* =(enode-get-projects)=
|
||||
- =(load-file enode-projects-file)=
|
||||
* =(enode-project-available project)=
|
||||
- Test to see if (e.g.) =~/development/<project>/scripts/sql/<project>_ENODE.sql= exists
|
||||
+ =(setq enode-current-connection-type <connection-type-of-project>)=
|
||||
+ =(enode-start-engine)=
|
||||
* =(enode-oracle-start-sql-engine)=
|
||||
- =(call-interactively 'sql-oracle)=. The command-line option
|
||||
set for =sqlplus= in the emacs customisation system include
|
||||
=/nolog=, which leaves the need to connect to a database
|
||||
until *after* the process has commenced.
|
||||
- Set SQL buffer settings
|
||||
* *MySQL addition* =(enode-mysql-start-engine)=
|
||||
- =t=: nothing can happen here as mysql doesn't support
|
||||
starting an interactive shell.
|
||||
+ Open the =*_ENODE.sql= file for the project
|
||||
+ =(setq enode-up t)= to declare that enode has started.
|
||||
+ =(enode-connection)= called interactively
|
||||
* =(enode-get-connections)=
|
||||
- =(enode-load-connections-list)=
|
||||
+ =(load-file enode-connections-file)=
|
||||
* =(enode-get-connections)=. As above.
|
||||
* =(enode-add-new-connection connection-description)=
|
||||
- =(enode-load-connections-list)=. As above.
|
||||
- =(enode-get-connections)=. As above.
|
||||
- Get attributes:
|
||||
+ *MySQL addition*: This needs to be genericised (or,
|
||||
proxied, really) to support capturing the different
|
||||
details required for the different connection types:
|
||||
| Connection type | Username | password | database | hostname | port |
|
||||
|-----------------+----------+----------+----------------+----------+-----------------------------------|
|
||||
| =oracle= | Y | Y | tnsnames entry | N | N |
|
||||
| =mysql= | Y | Y | Optional | Y | Defaults to 3306, yes if not this |
|
||||
|-----------------+----------+----------+----------------+----------+-----------------------------------|
|
||||
+ =conn-user=: Username
|
||||
+ =conn-connection=: Database connection: modelled by Oracle's TNSNames details
|
||||
+ =conn-prompt=: a three-character designator to use as the SQL*Plus prompt.
|
||||
- Add these details as a record in the =current-type-connections= list.
|
||||
- Update =all-connections= with the new =current-type-connections= list.
|
||||
- Update =enode-connections-file=.
|
||||
- =(enode-load-connections-list)=. As above.
|
||||
* =(enode-connect connection-description)=
|
||||
- =(enode-get-connections)=. As above.
|
||||
- Access and, maybe, set =enode-passwords-in-use=.
|
||||
- Based on =enode-current-connection-type=, one of the following:
|
||||
+ =(enode-oracle-connect conn-user conn-pass conn-connection conn-prompt)=
|
||||
* Issue the commands to the already-created iSQL session:
|
||||
: connect <conn-user>/<conn-pass>@<conn-connection>
|
||||
: set serverout on
|
||||
: set sqlprompt "<conn-prompt>> "
|
||||
+ =(enode-mysql-connect conn-user conn-pass conn-database conn-hostname conn-port conn-prompt)=
|
||||
* If the buffer for the SQL file has an iSQL buffer:
|
||||
- If that iSQL buffer has a running process:
|
||||
+ =(enode-mysql-reconnect conn-user conn-pass conn-database conn-hostname conn-port)=
|
||||
+ Otherwise:
|
||||
* Kill iSQL buffer
|
||||
* =(call-interactively 'sql-mysql)=
|
||||
- Otherwise =(call-interactively 'sql-mysql)=
|
||||
* =(enode-mysql-set-prompt conn-prompt)=
|
||||
- =(setq enode-currrent-connection connection-description)=
|
||||
- =(setq enode-connected t)=
|
|
@ -1,62 +0,0 @@
|
|||
|
||||
;; Copyright 2019 Éibhear Ó hAnluain
|
||||
|
||||
;; This file is part of ENODE.
|
||||
;;
|
||||
;; ENODE 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 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
;;
|
||||
;; ENODE 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 ENODE. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
(defun enode-mysql-start-sql-engine ()
|
||||
"A function to set up the SQL engine for connecting to a mysql
|
||||
or MariaDB database.
|
||||
|
||||
Until further notice, this function does nothing. It just returns
|
||||
T."
|
||||
t
|
||||
)
|
||||
|
||||
|
||||
(defun enode-mysql-connect (conn-user conn-pass conn-connection conn-hostname conn-prompt &optional conn-port)
|
||||
"A function to create to a mysql/mariadb database"
|
||||
|
||||
(if sql-buffer
|
||||
(if (not (get-buffer-process sql-buffer))
|
||||
(progn
|
||||
(kill-buffer sql-buffer)
|
||||
(enode-mysql-new-session conn-user conn-pass conn-connection conn-hostname conn-prompt conn-port)
|
||||
)
|
||||
(enode-mysql-reconnect conn-user conn-pass conn-connection conn-hostname conn-prompt conn-port)
|
||||
)
|
||||
(enode-mysql-new-session conn-user conn-pass conn-connection conn-hostname conn-prompt conn-port)
|
||||
)
|
||||
;; (setq enode-current-connection connection-description)
|
||||
;; (setq enode-connected t)
|
||||
)
|
||||
|
||||
(defun enode-mysql-new-session (conn-user conn-pass conn-connection conn-hostname conn-prompt conn-port)
|
||||
"A function to start a brand-new mysql/mariadb session"
|
||||
(let ((sql-user conn-user)
|
||||
(sql-database conn-connection)
|
||||
(sql-server conn-hostname)
|
||||
(sql-password conn-pass)
|
||||
)
|
||||
(sql-mysql)
|
||||
)
|
||||
)
|
||||
|
||||
(defun enode-mysql-reconnect (conn-user conn-pass conn-connection conn-hostname conn-prompt conn-port)
|
||||
"Undocumented, and incomplete"
|
||||
t
|
||||
)
|
||||
|
||||
(provide 'enode-mysql)
|
|
@ -344,12 +344,11 @@
|
|||
;; is set.
|
||||
|
||||
;; If we want oracle shtuff.
|
||||
(require 'enode-oracle) ;; Oracle only
|
||||
(require 'enode-mysql) ;; MySQL/MariaDB only
|
||||
(require 'enode-oracle)
|
||||
|
||||
;; Some handy stuff that really should be part of ENODE but isn't
|
||||
(require 'sql-extras)
|
||||
(require 'pls-extras) ;; Oracle only
|
||||
(require 'pls-extras)
|
||||
|
||||
;;
|
||||
;; Customisable stuff
|
||||
|
@ -483,7 +482,7 @@ This is the item whose information is displayed in the information window.")
|
|||
(defvar enode-current-connection-type nil
|
||||
"The current connection type: 'oracle, 'mysql, etc.")
|
||||
|
||||
(defvar enode-supported-connection-types '(oracle mysql)
|
||||
(defvar enode-supported-connection-types '(oracle)
|
||||
"The current connection type: 'oracle, 'mysql, etc.")
|
||||
|
||||
(defvar enode-current-connection nil
|
||||
|
@ -563,8 +562,6 @@ INTERACTIVE"
|
|||
"A function to start the SQL engine for the connection type"
|
||||
(cond ((eq 'oracle enode-current-connection-type)
|
||||
(enode-oracle-start-sql-engine))
|
||||
((eq 'mysql enode-current-connection-type)
|
||||
t)
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -583,12 +580,12 @@ INTERACTIVE"
|
|||
(active-buffer (current-buffer))
|
||||
)
|
||||
;; The user to connect as
|
||||
(setq conn-user (plist-get conn-details :conn-user))
|
||||
(setq conn-user (car conn-details))
|
||||
;; The database to connect to
|
||||
(setq conn-connection (plist-get conn-details :conn-connection))
|
||||
(setq conn-connection (caddr conn-details))
|
||||
;; The password to use: if it's not in the saved connection
|
||||
;; details...
|
||||
(setq conn-pass (if (not (plist-get conn-details :conn-pass))
|
||||
(setq conn-pass (if (not (cadr conn-details))
|
||||
;; ... if it's one of the locally saved
|
||||
;; passwords...
|
||||
(if (assoc connection-description
|
||||
|
@ -610,18 +607,12 @@ INTERACTIVE"
|
|||
enode-passwords-in-use))
|
||||
my-conn-pass))))
|
||||
;; The SQL prompt for the SQL engine
|
||||
(setq conn-prompt (plist-get conn-details :conn-prompt))
|
||||
(setq conn-hostname (plist-get conn-details :conn-hostname))
|
||||
(setq conn-port (plist-get conn-details :conn-port))
|
||||
(setq conn-prompt (cadddr conn-details))
|
||||
(cond ((eq 'oracle enode-current-connection-type)
|
||||
;; Connect.
|
||||
(enode-oracle-connect conn-user conn-pass conn-connection
|
||||
conn-prompt)
|
||||
)
|
||||
((eq 'mysql enode-current-connection-type)
|
||||
(enode-mysql-connect conn-user conn-pass conn-connection
|
||||
conn-hostname conn-prompt conn-port)
|
||||
)
|
||||
)
|
||||
;; Say who we're now connected to.
|
||||
(setq enode-current-connection connection-description)
|
||||
|
@ -904,20 +895,13 @@ of projects that are available."
|
|||
(read-from-minibuffer (format "Database for %s: " conn-desc)))
|
||||
;; Get the prompt that will be used
|
||||
(setq conn-prompt
|
||||
(read-from-minibuffer (format "PROMPT for %s: " conn-desc)))
|
||||
(setq conn-hostname (if (eq enode-current-connection-type 'mysql)
|
||||
(read-from-minibuffer (format "HOSTNAME for %s: " conn-desc))
|
||||
nil
|
||||
)
|
||||
)
|
||||
|
||||
(read-from-minibuffer (format "SQLPROMPT for %s: " conn-desc)))
|
||||
;; Add these details to the list of connections for the current type
|
||||
(setq current-type-connections
|
||||
(cons (list conn-desc
|
||||
conn-user
|
||||
nil
|
||||
conn-connection
|
||||
conn-hostname
|
||||
conn-prompt)
|
||||
current-type-connections))
|
||||
;; Replace the connections for this type in the list of all
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
(goto-char (point-max))
|
||||
(goto-char (re-search-backward "^-- Table: .+"))
|
||||
(insert (format "-- Table: %s\n\n" table-name))
|
||||
(insert (format "desc %s;\n\n" table-name))
|
||||
(insert (format "desc %s\n\n" table-name))
|
||||
(insert (format "select count(*) %s\nfrom %s;\n\n"
|
||||
table-name table-name))
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue