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/>. ;; along with ENODE. If not, see <http://www.gnu.org/licenses/>.
(defun enode-mysql-start-sql-engine () (defun enode-mysql-start-sql-engine ()
"A function to set up the SQL engine for connecting to a mysql or MariaDB database." "A function to set up the SQL engine for connecting to a mysql
(call-interactively 'sql-mysql) or MariaDB database.
;; Set the prompt regexps properly
(save-excursion Until further notice, this function does nothing. It just returns
(set-buffer "*SQL*") T."
(setq comint-prompt-regexp "^[0-9A-Za-z]\\{3\\}> ") t
(setq sql-prompt-regexp "^[0-9A-Za-z]\\{3\\}> ") )
(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))) (read-from-minibuffer (format "Database for %s: " conn-desc)))
;; Get the prompt that will be used ;; Get the prompt that will be used
(setq conn-prompt (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 ;; Add these details to the list of connections for the current type
(setq current-type-connections (setq current-type-connections
(cons (list conn-desc (cons (list conn-desc
conn-user conn-user
nil nil
conn-connection conn-connection
conn-hostname
conn-prompt) conn-prompt)
current-type-connections)) current-type-connections))
;; Replace the connections for this type in the list of all ;; Replace the connections for this type in the list of all