Yihong Theis
Yihong Theis

Reputation: 1

How to write a function that uses sqlite to connect to the database and query data in lisp

I have written this function:

(defun load-db (filename)
  (with-open-file (in filename)
    (with-standard-io-syntax
      (setf *db* (read in)))))

I have a database in local called xx.db, I want to use sqlite to connect it and something I can query like this:

(defvar *db* (connect "~/xx.db"))
(execute-single *db* "select ss_type from capitalization where lemma = ?" "A")

How can I do it? It won't run for the above query, and I also already include SQLite package, and give the path to the xx.db

Upvotes: 0

Views: 391

Answers (1)

Ehvince
Ehvince

Reputation: 18375

What database library did you try ?

With clsql, you can do something like:

(ql:quickload "clsql")
(clsql:connect "xx" :database-type :sqlite)
(clsql:execute-command "from ...")

Other DB libraries: https://github.com/CodyReichert/awesome-cl#database

Upvotes: 2

Related Questions