Adding *some* support for mysql/mariadb

This commit is contained in:
Éibhear Ó hAnluain 2019-05-24 14:53:26 +01:00
parent d61bb3b483
commit 466b950a3b
2 changed files with 41 additions and 8 deletions

View file

@ -17,12 +17,38 @@
;; 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."
(call-interactively 'sql-mysql)
;; Set the prompt regexps properly
(save-excursion
(set-buffer "*SQL*")
(setq comint-prompt-regexp "^[0-9A-Za-z]\\{3\\}> ")
(setq sql-prompt-regexp "^[0-9A-Za-z]\\{3\\}> ")
"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-database conn-hostname &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-database conn-hostname conn-port)
)
(enode-mysql-reconnect conn-user conn-pass conn-database conn-hostname conn-port)
)
(enode-mysql-new-session conn-user conn-pass conn-database conn-hostname conn-port)
)
(setq enode-current-connection connection-description)
(setq enode-connected t)
)
(defun enode-mysql-new-session (conn-user conn-pass conn-database conn-hostname conn-port)
"A function to start a brand-new mysql/mariadb session"
(let ((sql-user conn-user)
(sql-database conn-database)
(sql-server conn-hostname)
)
(sql-mysql)
)
)

View file

@ -898,13 +898,20 @@ 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 "SQLPROMPT for %s: " conn-desc)))
(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
)
)
;; 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