Forum: Ruby How to create a new database in ruby with sqlite3?

Bc8190701ce9ccc8011a238471cf6a77?d=identicon&s=25 Hakim Benbekhti (hakben)
on 2013-02-24 15:04
Here is what I wrote on my Terminal. I tried different ways of writing
sqlite3 but each time I get an error message.

Would someone know how I should write this code?

1.9.3p362 :002 > require 'sqlite3'
 => true
1.9.3p362 :003 > $db=SQLite3::Datatbase.new("dbfile")
NameError: uninitialized constant SQLite3::Datatbase
  from
/Users/hakimbenbekhti/.rvm/gems/ruby-1.9.3-p362/gems/sqlite3-1.3.7/lib/sqlite3/version.rb:19:in
`const_missing'
  from (irb):3
  from /Users/hakimbenbekhti/.rvm/rubies/ruby-1.9.3-p362/bin/irb:16:in
`<main>'
1.9.3p362 :004 > $db = sqlite3::Database.new("dbfile")
NameError: undefined local variable or method `sqlite3' for main:Object
  from (irb):4
  from /Users/hakimbenbekhti/.rvm/rubies/ruby-1.9.3-p362/bin/irb:16:in
`<main>'
1.9.3p362 :005 > $db = Sqlite3::Database.new("dbfile")
NameError: uninitialized constant Sqlite3
  from (irb):5
  from /Users/hakimbenbekhti/.rvm/rubies/ruby-1.9.3-p362/bin/irb:16:in
`<main>'
3853dd5371ac1e094fc45d6c2aa0e459?d=identicon&s=25 Carlo E. Prelz (Guest)
on 2013-02-24 15:35
(Received via mailing list)
Subject: How to create a new database in ruby with sqlite3?
  Date: dom 24 feb 13 11:04:09 +0900

Quoting Hakim Benbekhti (lists@ruby-forum.com):

> 1.9.3p362 :003 > $db=SQLite3::Datatbase.new("dbfile")

What about writing 'Database' instead of 'Datatbase'?

Carlo
Bc8190701ce9ccc8011a238471cf6a77?d=identicon&s=25 Hakim Benbekhti (hakben)
on 2013-02-24 15:44
Carlo E. Prelz wrote in post #1098778:
> Subject: How to create a new database in ruby with sqlite3?
>   Date: dom 24 feb 13 11:04:09 +0900
>
> Quoting Hakim Benbekhti (lists@ruby-forum.com):
>
>> 1.9.3p362 :003 > $db=SQLite3::Datatbase.new("dbfile")
>
> What about writing 'Database' instead of 'Datatbase'?
>
> Carlo

Yep, nothing more than that. How stupid...It will teach me to be more
patient and careful next time!
Thanks Carlo
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.