ruby syntax variabler i sql
Hej jeg har følgende kode som fejler#!/usr/bin/env ruby
require 'active_record'
require 'csv'
class MysqlConnection < ActiveRecord::Base
self.establish_connection(:adapter => 'jdbcmysql', :database => 'dwh' , :host => 'localhost', :username => 'root', :password => 'xxxxxxxx' )
CSV.open('/home/sij/bi/ant_del_tid.csv', 'r') do |row|
MysqlConnection.connection.insert('
INSERT INTO AntalMedarb
(
Navn
,Ant_Medarb_deltid
,Opdat_dato
)
VALUES
(
#{row[0]}
,#{row[1]}
,NOW()
)
')
end
end
Fejlen er
ActiveRecord::StatementInvalid: ActiveRecord::JDBCError: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '#{row[1]}
,NOW()
)' at line 10:
INSERT INTO AntalMedarb
(
Navn
,Ant_Medarb_deltid
,Opdat_dato
)
VALUES
(
#{row[0]}
,#{row[1]}
,NOW()
)