title: Create mysql rows/columns
body: <p>I wrote a little ruby script, which connects itself to a mysql database and creates a table (if this table doesn't exist yet). After this the script should store content in this table I try to store this data using: </p>
  
  <pre><code>Table.create(:foo =&gt; "bar", :foobar =&gt; "something", :blallala =&gt; "blololl") 
  </code></pre>
  
  <p>I also tried </p>
  
  <pre><code>Table.new(:foo =&gt; "bar", :foobar =&gt; "something", :blallala =&gt; "blololl") 
  </code></pre>
  
  <p>but it seems to do the same because I always get the error: </p>
  
  <blockquote>
    <p>Mysql::Error: Table 'my-username.my-dbname' doesn't exist: SHOW FULL FIELDS FROM table-name</p>
  </blockquote>
  
  <p>SO this is what I got so far:</p>
  
  <pre><code> ActiveRecord::Base.establish_connection(
                  :adapter =&gt; "mysql",
                  :host =&gt; "localhost",
                  :username =&gt; "my-username",
                  :password =&gt; "my-password",
                  :database =&gt; "my-db-name",
                  :encoding =&gt; "UTF8"
          )
  
          table_name = "my_table"
          unless ActiveRecord::Base.connection.tables.include? table_name
                  ActiveRecord::Schema.define do
                          create_table :"#{table_name}" do |table|
                                  table.column :foo, :string
                                  table.column :bar, :string
                                  table.column :blallala, :string
                          end
                  end
          end
  
          class Table &lt; ActiveRecord::Base
                  self.table_name = "#{table_name}"
          end
  
           Table.create(:foo =&gt; "bar", :foobar =&gt; "something", :blallala =&gt; "blololl")
           #Table.new(:foo =&gt; "bar", :foobar =&gt; "something", :blallala =&gt; "blololl")
  </code></pre>
  
  <p>So the question is: How do I actually create a columo/row and why does <code>Table.create(:foo =&gt; "bar", :foobar =&gt; "something", :blallala =&gt; "blololl")</code> not work?</p>