Function: emacsql-sqlite-connection
emacsql-sqlite-connection is a byte-compiled function defined in
emacsql-sqlite.el.
Signature
(emacsql-sqlite-connection VARIABLE FILE &optional SETUP USE-MODULE)
Documentation
Return the connection stored in VARIABLE to the database in FILE.
If the value of VARIABLE is a live database connection, return that.
Otherwise open a new connection to the database in FILE and store the connection in VARIABLE, before returning it. If FILE is nil, use an in-memory database. Always enable support for foreign key constrains. If optional SETUP is non-nil, it must be a function, which takes the connection as only argument. This function can be used to initialize tables, for example.
If optional USE-MODULE is non-nil, then use the external module even when Emacs was built with SQLite support. This is intended for testing purposes.
Source Code
;; Defined in ~/.emacs.d/elpa/emacsql-20261001.1544/emacsql-sqlite.el
;;; Utilities
(defun emacsql-sqlite-connection (variable file &optional setup use-module)
"Return the connection stored in VARIABLE to the database in FILE.
If the value of VARIABLE is a live database connection, return that.
Otherwise open a new connection to the database in FILE and store the
connection in VARIABLE, before returning it. If FILE is nil, use an
in-memory database. Always enable support for foreign key constrains.
If optional SETUP is non-nil, it must be a function, which takes the
connection as only argument. This function can be used to initialize
tables, for example.
If optional USE-MODULE is non-nil, then use the external module even
when Emacs was built with SQLite support. This is intended for testing
purposes."
(or (let ((connection (symbol-value variable)))
(and connection (emacsql-live-p connection) connection))
(set variable (emacsql-sqlite-open file nil setup use-module))))