SQLite3 sudden problem can't think of any changes I made?

#file one
requirbe_relative "dbmanage"
database_manager = DatabaseManager.new
database_manager.create_database("test.db")
database_manager.create_table("test.db", "test_table")

#dbmanage
  def create_table(database_name, table_name)
    database = SQLite3::Database.new("#{database_name}")
    create = database.execute <<-SQL
    create table "#{table_name}"
    SQL
  end

#error produced:
#../sqlite3/database.rb:91:in `initialize': near "
(SQLite3::SQLException)

I have not had any problems with this before, and I can't for the life
of me think of any changes I have made to the dbmanage file and it looks
like proper sql to me so what is going wrong :confused:

···

--
Posted via http://www.ruby-forum.com/.

#file one
requirbe_relative "dbmanage"
database_manager = DatabaseManager.new
database_manager.create_database("test.db")
database_manager.create_table("test.db", "test_table")

#dbmanage
def create_table(database_name, table_name)
database = SQLite3::Database.new("#{database_name}")

Why not

   database = SQLite3::Database.new(database_name)

or at least

   database = SQLite3::Database.new(database_name.to_s)

?

create = database.execute <<-SQL
create table "#{table_name}"
SQL
end

#error produced:
#../sqlite3/database.rb:91:in `initialize': near "
(SQLite3::SQLException)

I have not had any problems with this before, and I can't for the life
of me think of any changes I have made to the dbmanage file and it looks
like proper sql to me so what is going wrong :confused:

First of all that is not a proper table creation statement IMHO (no
columns defined) but maybe SQLite allows this. And then argument
"table_name" might actually contain a double quote which will break
the table creation. You should probably check, e.g. with this at the
beginning

raise sprintf("Invalid table name: %p", table_name) if /"/ =~ table_name

Kind regards

robert

···

On Wed, Jun 6, 2012 at 5:07 PM, bob wave <lists@ruby-forum.com> wrote:

--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/