I have never got the example in the User Guide to work. I can get it to list a result set if I manually insert rows into the Elements Sqlite3 database, but nothing gets written via code. Lately, I have been basing an attempt to write to a simple user, email database, from a webform. This is what I wrote: it's an adaptation of a "quick and dirty" script that someone posted to talk to a sqlite3 database.
I am not familiar enough with either newLISP or cgi to claim which of the small changes I made were absolutely necessary versus the ones which merely felt right stylistically. No doubt Cormullion or RickyBoy will be along soon to show us what real style looks like. :-) I for one will have my popcorn ready for that too.
Well, Bairui, what can I say? You nailed my funnies there, and it works fine now. Apart from removing the single quote where I had a symbol as an argument, you also used a NULL for the AUTOINCREMENT. In the past, I have successfully used an empty string, but NULLS as well. I just forgot. Did you make any other changes? The above is all I saw.
Thanks so much. With this as a barebones, I can go forward. Much appreciated.
Cheers!
You're right, there is a small error in the sqlite example on Wikibooks - the A% near the end should have single quotes... Now fixed.
Honestly I know very little about CGI or Sqlite, , other than my clumsy scribblings on the subject (https://newlisper.wordpress.com/2008/02 ... asy-steps/). I'm sure that getting all the punctuation and case right is half the battle...
Thanks, RickyBoy & Cormullion - it was the case sensitivity issues I was unsure about. I was fairly sure that the NULL was necessary - it seemed so in standalone tests of sqlite3.lsp. I don't think I made any other changes, jazper, apart from the aesthetic (load ...) -> (module "...").
FWIW, I tested sqlite3.lsp in the console and a standalone script before introducing the cgi layer. Primarily I did this because I always like to limit the number of variables when testing/fixing something, but a very real secondary in this case was my utter lack of cgi experience.
Thanks again, Bairui. You did spot some other errors: they were corrected in the code you posted. I had used (single quoted) symbols for arguments when defining the two queries "insrt" and "rslt". The modules had been working the way I loaded them before, but your code looks so much better. It was those and the NULL that made the difference, though I tested that with "null" lower case, which also worked.
Speaking about the "Elements" example (thanks to Cormullion for the latter fix) I never get even as far as the "like: query with ' A% ' as mentioned. I can't get the elements to load into Sqlite3, so the question of using queries never arises.
I will give that another try, though. Now that I have had a rest, I may spot something I have done wrong. So far, I have actually copied the code in verbatim, and re-checked a hundred times. But, a slip can happen.
; get POST data if present, use CONTENT_LENGTH variable
; if available
...
(begin
(set 'inline (read-line))
(when inline
(set 'params (get-vars inline)))
)
...
-- xytroxon
"Many computers can print only capital letters, so we shall not use lowercase letters."
-- Let's Talk Lisp (c) 1976