title: Ruby Mysql - load .sql file and execute
body: <p>I'm trying to load a .sql file in a ruby script into a string and then execute it.</p>
  
  <p>For some reason i'm getting a Syntax error, however if i copy and paste the statements directly into mysql it works just fine.</p>
  
  <p>Here's how i do it:</p>
  
  <pre><code>text = File.read(src_sql_file)
  new_text = text.DOINGSOMEGSUBSTUFF
  @dbh.select_db(dbname)
  sql = @dbh.prepare(new_text) 
  sql.execute()
  </code></pre>
  
  <p>i've also tried this:</p>
  
  <pre><code>sql = @dbh.prepare(new_text)  do |sth|
    sth.execute()
  end
  </code></pre>
  
  <p>and i always get:</p>
  
  <pre><code>Error message: 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
  
  'CREATE TABLE `the_logs` (
  `id` INT( 11 ) NOT NULL AUTO_INCREMENT PR' at line 5
  </code></pre>
  
  <p>where the sql for this looks like that:</p>
  
  <pre><code>CREATE TABLE `the_logs` (
  `id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY,
  `timestamp` INT( 11 ) NOT NULL ,
  ...
  </code></pre>
  
  <p>Any idea if i'm doing this wrong using prepare? i've also tried query.. didn't work either.</p>
  
  <p>Any help is greatly appreciated.
  T</p>