views:

25

answers:

1

Hello,

I am trying to import a file as a table in SQLite 3 using a Ruby script. I need to assign a tab separator, and I used the following code:

db = SQLite3::Database.new("meshdb2.db")
db.execute("CREATE TABLE IF NOT EXISTS pubmed(id integer primary key,prideID INT NOT NULL,pubmedID VARCHAR(10) NOT NULL)
db.prepare(".separator '\t'")

I am coming back with a "/usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.4/lib/sqlite3/errors.rb:62:in `check': near ".": syntax error (SQLite3::SQLException)" error, and I think it is because of the db.prepare() command. What is the proper command when I want to pass settings through Ruby to SQLite 3?

-Bobby

+1  A: 

You're missing the ending quotation mark on the second line after your query.

db.execute("CREATE TABLE IF NOT EXISTS pubmed(id integer primary key,prideID INT NOT NULL,pubmedID VARCHAR(10) NOT NULL")
# >------------------->------------------->------------------->------------------->------------------->----------------^
Jordan
I'm sorry, that's there in the real program, it was cut off when I was copy and pasting lines into the text box here. Any other ideas why this prepare() doesn't work?
Bobby