I cross-posted this at SO first, but then figured I may get a faster 
response here.

Trying to run the "hello world" type of example given here: 
http://sequel.jeremyevans.net/

The one modification I'm making is to connect to our MySQL server:

  DB = Sequel.connect(
    :adapter => 'mysql',
    :host => ENV['MYSQL_HOST'],
    :username => ENV['MYSQL_USER'],
    :password => ENV['MYSQL_PWD'],
    :dbname => 'test',
    :max_connections => 10
  )

  DB.create_table :items do

    primary_key :id
    String :name
    Float :price

  end

  items = DB[:items]

  items.insert(:name => 'abc', :price => rand*100)
  items.insert(:name => 'def', :price => rand*100)
  items.insert(:name => 'ghi', :price => rand*100)

  puts "Item count: #{items.count}"
  puts "The average price is: #{items.avg(:price)}"

I get the following errors and can't figure out what the problem is.:

Mysql::Error: No database selected 
/home/evan/.rvm/gems/ruby-1.9.3-p362/gems/sequel-4.9.0/lib/sequel/adapters/mysql.rb:175:in
 `query'
/home/evan/.rvm/gems/ruby-1.9.3-p362/gems/sequel-4.9.0/lib/sequel/adapters/mysql.rb:175:in
 `block in _execute'
/home/evan/.rvm/gems/ruby-1.9.3-p362/gems/sequel-4.9.0/lib/sequel/database/logging.rb:33:in
 
`log_yield'/home/evan/.rvm/gems/ruby-1.9.3-p362/gems/sequel-4.9.0/lib/sequel/adapters/mysql.rb:175:in
 `_execute'
/home/evan/.rvm/gems/ruby-1.9.3-p362/gems/sequel-4.9.0/lib/sequel/adapters/shared/mysql_prepared_statements.rb:34:in
 `block in execute'
/home/evan/.rvm/gems/ruby-1.9.3-p362/gems/sequel-4.9.0/lib/sequel/database/connecting.rb:229:in
 `block in 
synchronize'/home/evan/.rvm/gems/ruby-1.9.3-p362/gems/sequel-4.9.0/lib/sequel/connection_pool/threaded.rb:104:in
 `hold'
/home/evan/.rvm/gems/ruby-1.9.3-p362/gems/sequel-4.9.0/lib/sequel/database/connecting.rb:229:in
 `synchronize'
/home/evan/.rvm/gems/ruby-1.9.3-p362/gems/sequel-4.9.0/lib/sequel/adapters/shared/mysql_prepared_statements.rb:34:in
 
`execute'/home/evan/.rvm/gems/ruby-1.9.3-p362/gems/sequel-4.9.0/lib/sequel/adapters/mysql.rb:155:in
 `execute_dui'
/home/evan/.rvm/gems/ruby-1.9.3-p362/gems/sequel-4.9.0/lib/sequel/database/query.rb:43:in
 `execute_ddl'
/home/evan/.rvm/gems/ruby-1.9.3-p362/gems/sequel-4.9.0/lib/sequel/database/schema_methods.rb:617:in
 
`create_table_from_generator'/home/evan/.rvm/gems/ruby-1.9.3-p362/gems/sequel-4.9.0/lib/sequel/database/schema_methods.rb:188:in
 `create_table'

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to