开发者

SQlite3 and ruby simple INSERT INTO failing

This is a pretty simple problem and I'm pretty sure its just something I'm overlooking. Basically I'm trying to update a table with some values. Pretty straightforward and nothing that should gi开发者_JAVA技巧ve me a headache. Yet here I am.

This is being executed from Ruby on Rails with SQLite3 for the database. The code is as below:

def goodbye
require 'sqlite3'

db = SQLite3::Database.new( "test.db" )
rows = db.execute( " CREATE TABLE IF NOT EXISTS siteQueue
(
siteQueueKey INTEGER PRIMARY KEY,url TEXT,depth double,numLinks INTEGER);"
)

db.execute( 
"INSERT INTO "siteQueue"  VALUES(1,'www.yahoo.co.uk',1.0 ,20);
 INSERT INTO "siteQueue"  VALUES(2,'www.google.com', 2.5, 30);
 INSERT INTO "siteQueue"  VALUES(3, 'www.person.name', 9.0, 2);
 COMMIT;")

or

   db.execute( 
"INSERT INTO "siteQueue" 
(PRIMARY KEY,url,depth,numLinks)
 VALUES(1,'www.yahoo.co.uk',1.0 ,20);

 INSERT INTO "siteQueue" 
 (PRIMARY KEY,url,depth,numLinks)
  VALUES(2,'www.google.com', 2.5, 30);

 INSERT INTO "siteQueue" 
 (PRIMARY KEY,url,depth,numLinks)
 VALUES(3, 'www.person.name', 9.0, 2);

 COMMIT;")

Both of which are looking for something after siteQueue. I have no idea why.

Errors are here

app/controllers/say_controller.rb:16: syntax error, unexpected tIDENTIFIER, expecting ')'
"INSERT INTO "siteQueue"  VALUES(1,'www.yahoo.co.uk',1.0 ,20);
                       ^
app/controllers/say_controller.rb:17: syntax error, unexpected tIDENTIFIER, expecting kEND
 INSERT INTO "siteQueue"  VALUES(2,'www.google.com', 2.5, 30);

Has anyone got any ideas? This is more than likely something simple and I just need a fresh pair of eyes.


Its double Quotes -_-


db.execute( "INSERT INTO "siteQueue"

looks like too many quotes ....

"INSERT INTO 'siteQueue'


Change from:

db.execute( 
"INSERT INTO "siteQueue"  VALUES(1,'www.yahoo.co.uk',1.0 ,20);
 INSERT INTO "siteQueue"  VALUES(2,'www.google.com', 2.5, 30);
 INSERT INTO "siteQueue"  VALUES(3, 'www.person.name', 9.0, 2);
 COMMIT;")

to

db.execute( 
"INSERT INTO siteQueue  VALUES(1,'www.yahoo.co.uk',1.0 ,20);
 INSERT INTO siteQueue  VALUES(2,'www.google.com', 2.5, 30);
 INSERT INTO siteQueue  VALUES(3, 'www.person.name', 9.0, 2);
 COMMIT;")
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜