sqlite3 problem "no such table"

Started by jazper, February 19, 2010, 05:08:57 AM

Previous topic - Next topic

jazper

Hi

I am learning NewLisp:  having imported data (csv) into Sqlite3, I can work fine within the Firefox and Sqlite3Explorer tools.  However from within Newlisp IDE, the error reported is "no such table: MonFriDown".  As I say, the table is there, and usable:  in NewLisp, database opens ok. Code follows:

(load (append (env "NEWLISPDIR") "\modules\sqlite3.lsp"))
(if (sql3:open "SimonsTownLine.sqlite3")
(println "database opened/created")
(println "problem:  " (sql3:error)))

(define (query sql-text)
(set 'sqlarray (sql3:sql sql-text)) ; results of query
(if sqlarray
(map println sqlarray)
(println (sql3:error) " query problem ")))

(query "select * from MonFriDown")

 (sql3:error)            
 (sql3:close)  


Does anyone have similar problems with SQLite3, or is there something wrong with my code?

regards

Lutz

#1
Your code looks for  "SimonsTownLine.sqlite3" in the current directory, because it can't find an existing one there, it will create a new, empty one, which doesn't have the table.



You have to give the full path-file-name to your database, so it can find it.



PS: Use
(env "NEWLISPDIR") "/modules/sqlite3.lsp")

the forward slashes will work on Unix/Linux/OS X and Win32.



Or simply use:


(module "sqlite3.lsp")

jazper

#2
Thanks very much.  I had started with the full path, and had the same problem, that's why I changed it.  But I will try again.



Strangely, I can't get the 'Periodic table' from the NewLisp introduction to work either.



thanks again.

itistoday

#3
BTW, if you're interested in another sqlite3 module, you can take a look at http://www.rundragonfly.com/dragonfly_db_api">Dragonfly's. It uses a generic interface and ObjNL so that in the future you can easily change databases if needed.



If you check out the http://code.google.com/p/dragonfly-newlisp/source/checkout">mercurial repository for Dragonfly, there's some neat stuff in there that I've added recently for databases (with sqlite3 being the only one supported currently), including a basic ORM layer and some convenient functions (take a look in the dragonfly-framework/plugins-inactive/db folder). All of this isn't documented yet but it will be released soon with proper documentation.
Get your Objective newLISP groove on.