Fix empty output and emacsql-close error
This commit is contained in:
parent
8c02c3c397
commit
cbf302a7d1
|
@ -96,7 +96,7 @@ Return the connection object from `emacsql-sqlite'."
|
|||
(cl-defmethod chronometrist-to-file (hash-table (backend chronometrist-sqlite-backend) file)
|
||||
(with-slots (connection) backend
|
||||
(delete-file file)
|
||||
(emacsql-close connection)
|
||||
(when connection (emacsql-close connection))
|
||||
(setf connection nil)
|
||||
(chronometrist-create-file backend file)
|
||||
(cl-loop for date in (sort (hash-table-keys hash-table) #'string-lessp) do
|
||||
|
@ -205,6 +205,6 @@ s-expressions in a text column."
|
|||
(cl-defmethod chronometrist-replace-last ((backend chronometrist-sqlite-backend) plist)
|
||||
(emacsql db [:delete-from events :where ]))
|
||||
|
||||
(provide 'chronometrist-sqlite3)
|
||||
(provide 'chronometrist-sqlite)
|
||||
|
||||
;;; chronometrist-sqlite3.el ends here
|
||||
;;; chronometrist-sqlite.el ends here
|
||||
|
|
|
@ -137,7 +137,7 @@ Return the connection object from `emacsql-sqlite'."
|
|||
(cl-defmethod chronometrist-to-file (hash-table (backend chronometrist-sqlite-backend) file)
|
||||
(with-slots (connection) backend
|
||||
(delete-file file)
|
||||
(emacsql-close connection)
|
||||
(when connection (emacsql-close connection))
|
||||
(setf connection nil)
|
||||
(chronometrist-create-file backend file)
|
||||
(cl-loop for date in (sort (hash-table-keys hash-table) #'string-lessp) do
|
||||
|
@ -276,9 +276,9 @@ s-expressions in a text column."
|
|||
|
||||
** Provide
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(provide 'chronometrist-sqlite3)
|
||||
(provide 'chronometrist-sqlite)
|
||||
|
||||
;;; chronometrist-sqlite3.el ends here
|
||||
;;; chronometrist-sqlite.el ends here
|
||||
#+END_SRC
|
||||
|
||||
* Local variables :noexport:
|
||||
|
|
|
@ -1882,8 +1882,19 @@ Return value is either a list in the form
|
|||
|
||||
;; [[file:chronometrist.org::*migrate][migrate:1]]
|
||||
(defun chronometrist-migrate (&optional input-backend-keyword input-file
|
||||
output-backend-keyword output-file)
|
||||
"Convert from one Chronometrist backend to another."
|
||||
output-backend-keyword output-file
|
||||
&rest load-files)
|
||||
"Convert from one Chronometrist backend to another.
|
||||
|
||||
INPUT-BACKEND-KEYWORD and OUTPUT-BACKEND-KEYWORD must be keywords
|
||||
corresponding to entries in `chronometrist-backends-alist'.
|
||||
|
||||
INPUT-FILE and OUTPUT-FILE must be file names. INPUT-FILE must
|
||||
already exist.
|
||||
|
||||
LOAD-FILES must be paths to Elisp files. These files are `load'ed
|
||||
before conversion. They may be used to point to Chronometrist
|
||||
source files to be used."
|
||||
(interactive)
|
||||
(let* ((input-backend-keyword (or input-backend-keyword
|
||||
(chronometrist-read-backend-name "Backend to convert: " chronometrist-backends-alist nil t)))
|
||||
|
@ -1923,7 +1934,9 @@ Return value is either a list in the form
|
|||
"--eval=(cl-loop for (pkg . desc) in package-alist
|
||||
when (string-match-p \"^chronometrist\" (symbol-name pkg))
|
||||
do (require pkg))"
|
||||
(format "--eval=(chronometrist-to-file (chronometrist-backend-hash-table (chronometrist-get-backend %s)) (chronometrist-get-backend %s) %S)"
|
||||
(format "--eval=(cl-loop for file in (quote %S) do (load file))" load-files)
|
||||
;; the hash table slot may be empty, so we generate the hash table from scratch
|
||||
(format "--eval=(chronometrist-to-file (chronometrist-to-hash-table (chronometrist-get-backend %s)) (chronometrist-get-backend %s) %S)"
|
||||
input-backend-keyword output-backend-keyword output-file))
|
||||
(message "Conversion aborted."))))
|
||||
;; migrate:1 ends here
|
||||
|
|
|
@ -2910,8 +2910,19 @@ We apply the same hack as in the [[hack-note-plist-group-insert][insert]] method
|
|||
*** migrate :command:
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(defun chronometrist-migrate (&optional input-backend-keyword input-file
|
||||
output-backend-keyword output-file)
|
||||
"Convert from one Chronometrist backend to another."
|
||||
output-backend-keyword output-file
|
||||
&rest load-files)
|
||||
"Convert from one Chronometrist backend to another.
|
||||
|
||||
INPUT-BACKEND-KEYWORD and OUTPUT-BACKEND-KEYWORD must be keywords
|
||||
corresponding to entries in `chronometrist-backends-alist'.
|
||||
|
||||
INPUT-FILE and OUTPUT-FILE must be file names. INPUT-FILE must
|
||||
already exist.
|
||||
|
||||
LOAD-FILES must be paths to Elisp files. These files are `load'ed
|
||||
before conversion. They may be used to point to Chronometrist
|
||||
source files to be used."
|
||||
(interactive)
|
||||
(let* ((input-backend-keyword (or input-backend-keyword
|
||||
(chronometrist-read-backend-name "Backend to convert: " chronometrist-backends-alist nil t)))
|
||||
|
@ -2951,7 +2962,9 @@ We apply the same hack as in the [[hack-note-plist-group-insert][insert]] method
|
|||
"--eval=(cl-loop for (pkg . desc) in package-alist
|
||||
when (string-match-p \"^chronometrist\" (symbol-name pkg))
|
||||
do (require pkg))"
|
||||
(format "--eval=(chronometrist-to-file (chronometrist-backend-hash-table (chronometrist-get-backend %s)) (chronometrist-get-backend %s) %S)"
|
||||
(format "--eval=(cl-loop for file in (quote %S) do (load file))" load-files)
|
||||
;; the hash table slot may be empty, so we generate the hash table from scratch
|
||||
(format "--eval=(chronometrist-to-file (chronometrist-to-hash-table (chronometrist-get-backend %s)) (chronometrist-get-backend %s) %S)"
|
||||
input-backend-keyword output-backend-keyword output-file))
|
||||
(message "Conversion aborted."))))
|
||||
#+END_SRC
|
||||
|
|
Reference in New Issue