Function: emacsql-sqlite-open
emacsql-sqlite-open is a byte-compiled function defined in
emacsql-sqlite.el.
Signature
(emacsql-sqlite-open FILE &optional DEBUG SETUP USE-MODULE)
Documentation
Open a connection to the database stored in FILE using an SQLite back-end.
Automatically use the best available back-end, as returned by
emacsql-sqlite-default-connection.
If FILE is nil, use an in-memory database. If optional DEBUG is non-nil, log all SQLite commands to a log buffer, for debugging purposes. 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
(defun emacsql-sqlite-open (file &optional debug setup use-module)
"Open a connection to the database stored in FILE using an SQLite back-end.
Automatically use the best available back-end, as returned by
`emacsql-sqlite-default-connection'.
If FILE is nil, use an in-memory database. If optional DEBUG is
non-nil, log all SQLite commands to a log buffer, for debugging
purposes. 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."
(when file
(make-directory (file-name-directory file) t))
(let* ((class (emacsql-sqlite-default-connection use-module))
(connection (make-instance class :file file)))
(when debug
(emacsql-enable-debugging connection))
(emacsql connection [:pragma (= foreign-keys on)])
(when setup
(funcall setup connection))
connection))