0

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

vCillusion
  • 1,749
  • 20
  • 33
  • 1
    Please read this article, before asking a question [How do I ask a good question?](https://stackoverflow.com/help/how-to-ask) – Hamed Jul 05 '18 at 20:55

1 Answers1

1

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

Ehvince
  • 17,274
  • 7
  • 58
  • 79
  • I used wordnet, but I have wordnet.db file in my local. Do I need open the file or open the database, how I can insert my query? – Yihong Theis Jul 06 '18 at 22:07
  • Word net is a series of files that would need to be imported into sql. There appear to be a number of github projects That deal with wordnet, this one github.com/TheDarkTrumpet/cl-wordnet claims to be a cl interface to an sql wordnet.. if you ask a question again please provide more context so we understand what you are asking – David Hodge Jul 08 '18 at 10:20
  • I have wordnet database files which stored in wordnet.db in different directory, I want to write functions that can connect my database wordnet.db in cl sqlite, then query two tables. I am trying to write functions in aquamacs. – Yihong Theis Jul 09 '18 at 13:11
  • I think the first thing is to make sure that wordnet.db is indeed an sqlite database - you can use http://sqlitebrowser.org/ to make sure that it is indeed a sqllite db and that sqlite is properly installed. If it works, then clsql is a very easy way to connect to it from lisp. – David Hodge Jul 10 '18 at 01:01