5

When using korma.db, defdb can take a sqlite3 helper to establish a connexion to a sqlite3 database. However, I've tried placing the database on the root of the project directory, alongside project.clj, and on the resources directory, but when I try to use the db I get:

Failure to execute query with SQL: SELECT "examples".* FROM "examples" :: [] SQLException: Message: [SQLITE_ERROR] SQL error or missing database (no such table: examples)

Needless to say my sqlite database contains an examples table. When trying to do this, I get a sqlite.db file of zero bytes placed on the root project dir.

I'm doing this from lein repl within the project, by the way.

Edit: This is what I do when it fails:

(use 'korma.db)
(defdb db (sqlite3 {:db "filename.db"}))
(use 'korma.core)
(defentity examples)
(select examples)
Joel Quiles
  • 811
  • 1
  • 9
  • 16
user3112185
  • 101
  • 5
  • 1
    Please provide the code you used to connect to the db and send the query – ProGM Dec 17 '13 at 17:41
  • I'll add it to the question. – user3112185 Dec 17 '13 at 18:13
  • Not getting the same result. I've tried the statements you gave, and got a "filename.db" created in the root directory as I might expect. I added a "examples" table to that database, and then it worked fine. Do you still have this problem? – Tom Parker-Shemilt Mar 16 '14 at 14:18

1 Answers1

1

Just in case anybody is wondering or runs into this...

Using version [korma "0.4.2"] and [org.xerial/sqlite-jdbc "3.7.15-M1"] in my project.clj:

My project structure looks like:

root/project.clj
root/db/dev.sqlite3
root/src/...

and this is how I use korma to access the db:

(use 'korma.db)
(defdb mydb {:classname "org.sqlite.JDBC"
      :subprotocol "sqlite"
      :subname "db/dev.sqlite3"})

Basically, using subname, I'm able to search in the root of the lein project. I added db/ in the subname per my dir structure above.

Joel Quiles
  • 811
  • 1
  • 9
  • 16