From 466b950a3b01d17c6f4f98214ec2586f0f08ecc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ibhear=20=C3=93=20hAnluain?= Date: Fri, 24 May 2019 14:53:26 +0100 Subject: [PATCH] Adding *some* support for mysql/mariadb --- enode-lisp/enode-mysql.el | 40 ++++++++++++++++++++++++++++++++------- enode-lisp/enode.el | 9 ++++++++- 2 files changed, 41 insertions(+), 8 deletions(-) diff --git a/enode-lisp/enode-mysql.el b/enode-lisp/enode-mysql.el index efdb673..709e74d 100644 --- a/enode-lisp/enode-mysql.el +++ b/enode-lisp/enode-mysql.el @@ -17,12 +17,38 @@ ;; along with ENODE. If not, see . (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) ) ) diff --git a/enode-lisp/enode.el b/enode-lisp/enode.el index 8a8636c..0fe06f4 100755 --- a/enode-lisp/enode.el +++ b/enode-lisp/enode.el @@ -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