sqlite3 problem "no such table"

Featuring the Dragonfly web framework
Locked
jazper
Posts: 92
Joined: Thu Dec 10, 2009 8:26 am
Location: South Africa

sqlite3 problem "no such table"

Post by 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:

Code: Select all

(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
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: sqlite3 problem "no such table"

Post by Lutz »

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

Code: Select all

(env "NEWLISPDIR") "/modules/sqlite3.lsp")
the forward slashes will work on Unix/Linux/OS X and Win32.

Or simply use:

Code: Select all

(module "sqlite3.lsp")

jazper
Posts: 92
Joined: Thu Dec 10, 2009 8:26 am
Location: South Africa

Re: sqlite3 problem "no such table"

Post by jazper »

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
Posts: 429
Joined: Sun Dec 02, 2007 5:10 pm
Contact:

Re: sqlite3 problem "no such table"

Post by itistoday »

BTW, if you're interested in another sqlite3 module, you can take a look at 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 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.

Locked