Afficher un message
Vieux 21/02/2008, 15h03   #1
Tom Cloyd
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut beginner's problem with sqlite3

It would be ful if the sqlite3-ruby documentation offered one or two
complete examples, as without these I am unable to figure out several
syntax questions, so I'm having to guess, and I'm not guessing right.

I'm inputing a simple text file and trying to use it to generate an
table containing 4 fields (columns). I'm tracking the program with logger.

Here's the table creation code, which I'm not entirely sure is correct,
but there are no errors produced by it:

db = SQLite3:atabase.new( "sqlite-demo.sqlite" )
db.execute( 'CREATE TABLE newsheap (datecol titlecol urlcol summarycol)' )

I then read four physical records into, respectively, variables date,
title, url, and summary. Then I try to output them to the table with
this statement, about which I feel even less certain, and it's here that
the error is produced:

db.execute( 'INSERT INTO newsheap(datecol titlecol urlcol summarycol)
VALUES(date title url summary)' )

The logger output this produces:
E, [2008-02-21T05:52:45.358561 #11133] ERROR -- : near "titlecol":
syntax error

I've spent hours trying many variations to probe the syntax, and I keep
getting the same error.

I keep thinking that I'm somehow not being clear to ruby, in the
transition between ruby variables and variables in the sql statement,
but I cannot find the problem. For now, I'm stumped. Any would be
appreciated.

Tom


  Réponse avec citation
 
Page generated in 0,05740 seconds with 9 queries