Download and unzip SQLITE into a directory. I used c:\program files\sqlite3. This path will need to be referred to as c:\progra~1\sqlite3 in your lisp code and any batch files. Be sure to also download the associated executable file, which provides about 27 “dot” utility commands. Test that the systems works by creating a table and populating with data. To get started, create a batch file that starts SQLITE with the database name of interest, which is passed to the executable as a parameter. To create the database named “mydb”, the contents of sqlite.bat would be:
At the sqlite prompt both dot and SQL commands can be submitted. To retain a record of the commands used to create your database, place them in a plain text file and then use the .read command to read that file into SQLITE. Here are the contents of my “create-tables.txt” file:
To execute, read in create-tables.txt at the sqlite prompt:
You can check that the table was created with the .schema command. Next insert a value. Either type it directly at the sqlite prompt, or read it from a file.
And query it out:
If you retrieve your row, you are all set to move on. Note that the assigned value of ab_id is NULL. Let the database assign the autoincrement field.
;;;; Programming - SQLite
(define-key sql-mode-map [f5] ‘sql-send-region)
(define-key sql-mode-map [f4] ‘sql-send-buffer)))
;;Hook for reacting to changes of sql-buffer
;; (setq sql-database “~/owncloud/misc/pm/pm.sqlite”)
(defun sql-connect-preset (name)
“Connect to a predefined SQL connection listed in
(eval(let ,(cdr (assoc name sql-connection-alist))
(flet ((sql-get-login (&rest what)))
;; (add-hook ‘sql-interactive-mode-hook ‘my-sql-save-history-hook)