[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/emacsql c5e1ccef73 257/427: Flesh out the rest of mysql-co
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/emacsql c5e1ccef73 257/427: Flesh out the rest of mysql-connection's constructor. |
Date: |
Tue, 13 Dec 2022 02:59:49 -0500 (EST) |
branch: elpa/emacsql
commit c5e1ccef7369025b25c5d85932ac898726bc9947
Author: Christopher Wellons <wellons@nullprogram.com>
Commit: Christopher Wellons <wellons@nullprogram.com>
Flesh out the rest of mysql-connection's constructor.
---
emacsql-mysql.el | 36 ++++++++++++++++++++----------------
emacsql-psql.el | 4 +---
emacsql-sqlite.el | 4 +---
emacsql.el | 7 +++++++
4 files changed, 29 insertions(+), 22 deletions(-)
diff --git a/emacsql-mysql.el b/emacsql-mysql.el
index 17f11be99c..4930497b07 100644
--- a/emacsql-mysql.el
+++ b/emacsql-mysql.el
@@ -21,23 +21,27 @@
(object "LONGTEXT")
(nil "LONGTEXT")))))
-(defun emacsql-mysql (dbname)
+(cl-defun emacsql-mysql (database &key user password host port debug)
"Connect to a MySQL server using the mysql command line program."
- (let* ((process-connection-type t)
- (buffer (generate-new-buffer " *emacsql-mysql*"))
- (mysql emacsql-mysql-executable)
- (command (mapconcat #'shell-quote-argument
- (list mysql "-rfBNL" "--skip-pager" dbname)
- " "))
- (process (start-process-shell-command
- "emacsql-mysql" buffer (concat "stty raw &&" command)))
- (connection (make-instance 'emacsql-mysql-connection
- :process process
- :dbname dbname)))
- (setf (process-sentinel process)
- (lambda (proc _) (kill-buffer (process-buffer proc))))
- (emacsql connection [:set-session (= sql-mode 'NO_BACKSLASH_ESCAPES)])
- (emacsql-register connection)))
+ (let* ((mysql (executable-find emacsql-mysql-executable))
+ (command (list database "--skip-pager" "-rfBNL" mysql)))
+ (when user (push (format "--user=%s" user) command))
+ (when password (push (format "--password=%s" password) command))
+ (when host (push (format "--host=%s" host) command))
+ (when port (push (format "--port=%s" port) command))
+ (let* ((process-connection-type t)
+ (buffer (generate-new-buffer " *emacsql-mysql*"))
+ (command (mapconcat #'shell-quote-argument (nreverse command) " "))
+ (process (start-process-shell-command
+ "emacsql-mysql" buffer (concat "stty raw &&" command)))
+ (connection (make-instance 'emacsql-mysql-connection
+ :process process
+ :dbname database)))
+ (setf (process-sentinel process)
+ (lambda (proc _) (kill-buffer (process-buffer proc))))
+ (when debug (emacsql-enable-debugging connection))
+ (emacsql connection [:set-session (= sql-mode 'NO_BACKSLASH_ESCAPES)])
+ (emacsql-register connection))))
(defmethod emacsql-close ((connection emacsql-mysql-connection))
(let ((process (emacsql-process connection)))
diff --git a/emacsql-psql.el b/emacsql-psql.el
index a6cd725b86..d96a78ad1a 100644
--- a/emacsql-psql.el
+++ b/emacsql-psql.el
@@ -59,9 +59,7 @@
:dbname dbname)))
(setf (process-sentinel process)
(lambda (proc _) (kill-buffer (process-buffer proc))))
- (when debug
- (setf (emacsql-log-buffer connection)
- (generate-new-buffer " *emacsql-log*")))
+ (when debug (emacsql-enable-debugging connection))
(mapc (apply-partially #'emacsql-send-message connection)
'("\\pset pager off"
"\\pset null nil"
diff --git a/emacsql-sqlite.el b/emacsql-sqlite.el
index 55ec04e5cf..a8afc23cdd 100644
--- a/emacsql-sqlite.el
+++ b/emacsql-sqlite.el
@@ -43,9 +43,7 @@ buffer. This is for debugging purposes."
(emacsql-wait connection)
(emacsql connection [:pragma (= busy-timeout $s1)]
(/ (* emacsql-global-timeout 1000) 2))
- (when debug
- (setf (emacsql-log-buffer connection)
- (generate-new-buffer " *emacsql-log*")))
+ (when debug (emacsql-enable-debugging connection))
(emacsql-register connection)))
(defmethod emacsql-close ((connection emacsql-sqlite-connection))
diff --git a/emacsql.el b/emacsql.el
index fe13cd908f..f79150aaa3 100644
--- a/emacsql.el
+++ b/emacsql.el
@@ -73,6 +73,7 @@ If nil, wait forever.")
:accessor emacsql-process)
(log-buffer :type (or null buffer)
:initarg :log-buffer
+ :initform nil
:accessor emacsql-log-buffer
:documentation "Output log (debug).")
(types :allocation :class
@@ -103,6 +104,12 @@ SQL expression.")
"Get proccess buffer for CONNECTION."
(process-buffer (emacsql-process connection)))
+(defmethod emacsql-enable-debugging ((connection emacsql-connection))
+ "Enable debugging on this"
+ (unless (buffer-live-p (emacsql-log-buffer connection))
+ (setf (emacsql-log-buffer connection)
+ (generate-new-buffer " *emacsql-log*"))))
+
(defmethod emacsql-log ((connection emacsql-connection) message)
"Log MESSAGE into CONNECTION's log.
MESSAGE should not have a newline on the end."
- [nongnu] elpa/emacsql cf16cdb2f8 217/427: Add a special characters test., (continued)
- [nongnu] elpa/emacsql cf16cdb2f8 217/427: Add a special characters test., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 2db4a84598 225/427: Allow os tuples to be specified as an env var., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql ba2fac7701 228/427: Update the README., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql af2cdddca1 231/427: Squash a bunch of bugs., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql d3fa5b908f 234/427: Add funcall operator., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql b29ea275d4 236/427: Tweak limitations notes., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 45ac14390a 239/427: Fix up emacsql.el header to match new syntax., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 7c774ffe12 248/427: Improve MySQL error parsing., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 89e42aed13 253/427: Add docstring to emacsql-mysql., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 5c423307a8 254/427: Fix README typo., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql c5e1ccef73 257/427: Flesh out the rest of mysql-connection's constructor.,
ELPA Syncer <=
- [nongnu] elpa/emacsql be9c46c274 259/427: Change the way tuples are computed., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql de9b3633d2 262/427: Oops do clean with distclean., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 0f5f560f8b 267/427: Fix README example typo., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 203cff9007 269/427: Rename the project to EmacSQL., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 38bd19ed6f 276/427: Oops, use the right equality., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 50e47ee01a 278/427: Remove shell quote., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 6c7576e497 295/427: Rename condition emacsql-lock to emacsql-locked., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 39ce3b9736 287/427: Smarter identifier identification in expressions., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 20391923d1 292/427: Add option to disable local builds., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql b375cd7759 294/427: Bump version number due to protocol change., ELPA Syncer, 2022/12/13