sql - Getting "syntax error, unexpected tIDENTIFIER..." when trying to insert rows into SQLite via Ruby -


anyone have ideas? error message in bash...

insert_code_sam.rb:31: syntax error, unexpected tidentifier, expecting ')'     "insert index1 (name) values ("test1");"                                              ^ insert_code_sam.rb:32: syntax error, unexpected ')', expecting end-of-input 

in single file insert_code_sam.rb, i'm trying create new db, create 2 tables, , insert test row. sqlite table gets created without problem, can't seem insert rows.

require "sqlite3"  db = sqlite3::database.new( "new_database.db" )  db.execute(    "create table index1 (     id integer primary key autoincrement,      name text,     tagline text,     blurb text,     photo_url text);" )   db.execute(    "create table student_profile (     id integer primary key autoincrement,      name_id integer,     thumbnail_url text,     background_url text,     quote text,     bio text,     education text,     work text,     github text,     treehouse text,     codeschool text,     coderwall text);" )     db.execute(     "insert index1 (name) values ("test1");"   ) 

you prematurely ending string – code not valid ruby syntax. sqlite expects single quoted strings, anyway. solution use single quotes values:

db.execute(   "insert index1 (name) values ('test1');" ) 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -