emacs-edbi
emacs-edbi copied to clipboard
Query execute does not return?
Just found this for the day - using with emacs 29. I can get it to talk to me sqlite database and describe the tables fine. However when I try to query the database via C-c C-c
I can see it getting as far as edbi:dbview-query-editor-execute-command
but then the asynchronous function below is entered, but never seems to return.
Can anyone confirm if this should still work - I notice the package is quite old, but I can see people commenting on Reddit just a few years a go that it was working fine. It's exactly what I need to happy to patch the function if needs be!
(defun edbi:dbview-query-execute (conn sql result-buf)
"[internal] Execute SQL and rendering results."
(lexical-let ((conn conn) (time-begin (float-time))
(sql sql) (result-buf result-buf))
;; THE CODE GETS THIS FAR FOR SURE - BUT THEN NO MESSAGE RETURNED
(cc:semaphore-with edbi:dbview-query-execute-semaphore
(lambda (x)
(message "EDBI: Waiting for the query...")
(deferred:$
(edbi:seq
(edbi:prepare-d conn sql)
(edbi:execute-d conn nil)
(lambda (exec-result)
(message "Result Code: %S / %.3f seconds"
exec-result (- (float-time) time-begin))
(cond
;; SELECT
((or (equal "0E0" exec-result)
(and exec-result (numberp exec-result))) ; some DBD returns rows number
(edbi:dbview-query-editor-history-add sql)
(lexical-let (rows header (exec-result exec-result))
(edbi:seq
(header <- (edbi:fetch-columns-d conn))
(rows <- (edbi:fetch-d conn edbi:dbview-query-result-fetch-num))
(lambda (x)
(cond
((or rows (equal "0E0" exec-result)) ; select results
(if rows
(edbi:dbview-query-result-open conn result-buf header rows)
(progn
(message "No rows returned.")
(kill-buffer result-buf))))
(t ; update results?
(edbi:dbview-query-result-text conn result-buf exec-result)))))))
;; ERROR
((null exec-result)
(edbi:dbview-query-result-error conn result-buf))
;; UPDATE etc
(t
(edbi:dbview-query-editor-history-add sql)
(edbi:dbview-query-result-text conn result-buf exec-result)))))
(deferred:error it
(lambda (err) (message "ERROR : %S" err))))))))