fukamachi / cl-dbi

Database independent interface for Common Lisp
205 stars 28 forks source link

SQLite3 driver install #39

Closed defunkydrummer closed 7 years ago

defunkydrummer commented 7 years ago

Hi Eitaro,

First of all, thank you very much for the amazing number of systems you are developing for Common Lisp, like clack, lack, ningle and Caveman2.

I am having the following problem when installing the DBD driver for SQLite:

(quicklisp:quickload "dbd-sqlite3")
To load "dbd-sqlite3":
  Load 1 ASDF system:
    dbd-sqlite3
; Loading "dbd-sqlite3"

I get the following error:

Unable to load any of the alternatives:
   ((:DEFAULT "libsqlite3") (:DEFAULT "sqlite3"))
   [Condition of type CFFI:LOAD-FOREIGN-LIBRARY-ERROR]

EDIT: I see that CFFI is trying to find the external library for SQLITE3.

Do you have a suggestion on which SQLITE3 library to use with CFFI? I was caught off-guard, i thought that the CL-DBI SQLITE3 "driver" already included the "driver" ;-P

defunkydrummer commented 7 years ago

Sorry Eitaro,

I should have read the "Installation" section of CL-SQLITE, in which the author says:

"This package does not include SQLite library. It should be installed and loadable with regular FFI mechanisms. On Linux and Mac OS X SQLite is probably already installed (if it's not installed, use native package manager to install it). On Windows PATH environment variable should contain path to sqlite3.dll."

In any case, perhaps you could put a warning on your CL-DBI page, that for SQLITE3, the CL-SQLITE library should be installed according to the instructions provided by the author. Quicklisp will not install SQLITE correctly automatically.

In that way, noobs like me won't be bothering you opening issues ... !

defunkydrummer commented 7 years ago

For the noobies to CL out there, like me, who might have the same problem:

These were the steps i followed to load Sqlite3. In my case the environment is windows (yes... yes...) and thus i placed the .dll file under the local-projects/cffi-libs directory, a directory I arbitrarily created.

;; adding the foreign library directory so CFFI can locate the dll
CL-USER> (push #P"c:/Users/fegoavil010/Documents/instalados/lisp-portacle/portacle/all/quicklisp/local-projects/cffi-libs/" cffi:*foreign-library-directories*) 
(#P"c:/Users/fegoavil010/Documents/instalados/lisp-portacle/portacle/all/quicklisp/local-projects/cffi-libs/")

;; defining the foreign library so CFFI knows it and can load it
CL-USER> (cffi:define-foreign-library sqlite3 (t (:default "sqlite3")))
SQLITE3

;; loading the library 
CL-USER> (cffi:load-foreign-library 'sqlite3)
#<CFFI:FOREIGN-LIBRARY SQLITE3 "sqlite3.dll">

Afterwards, system "sqlite" can be loaded without any error:

CL-USER> (quicklisp:quickload "sqlite")
To load "sqlite":
  Load 1 ASDF system:
    sqlite
; Loading "sqlite"
[package sqlite.cache]............................
[package sqlite]....
("sqlite")
CL-USER> 

Closing the issue !