From: "Ara.T.Howard" Date: 2005-11-04T04:13:38+09:00 Subject: Re: Fwd: sqlite - and ruby On Fri, 4 Nov 2005, Ammon Christiansen wrote: > I wanted to share my experiences getting sqlite3 and ruby working in a user > account on Linux (installed in local directory (using > --prefix=/my/home/directory/whateverbin)). You can see the conversation > between Jamis and me to get an example working. > > I had to do one more thing besides what is below: > export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/libsqlite3.so if you do export LD_RUN_PATH=/path/to/libsqlite3.so __before__ compiling neither you, or anyone else running your software will need to have LD_LIBRARY_PATH set. it's a one time thing. > > A symbolic link to the current directory isn't good enough. > > Duane and Jamis have been very helpful getting me started with Ruby. Thanks > guys > > Ammon > > On 11/3/05, Jamis Buck wrote: >> >> On Nov 3, 2005, at 10:01 AM, Ammon Christiansen wrote: >> >>> 1 require 'rubygems' >>> 2 require 'sqlite3' >>> 3 #require 'sqlite3-ruby' >>> Thanks for catching the SQLite3 thing. Am I doing anything else >>> wrong on line 6: I get the error >>> >>> ajc55@chocolate:~/Research/ParseXML$ ruby testsqlite.rb >>> /fse/ajc55/rubybin/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.1.0/lib/ >>> sqlite3/database.rb:106:in `initialize': undefined method `fetch' >>> for 420:Fixnum (NoMethodError) >>> from testsqlite.rb:6 >>> >>> >>> 4 #require 'sqlite-ruby' >>> 5 >>> 6 db = SQLite3::Database.new( 'sample.db', 0644 ) >> >> Looks like the problem is the 0644 you're giving it. >> SQLite3::Database.new takes two parameters, the second one optional. >> The second one is supposed to be a Hash of options to use when >> opening the database. (There isn't a way to specify the file mode on >> the new file, unfortunately.) >> >> If you take out the 0644 parameter, it should work fine. >> >> - Jamis >> >>> 7 >>> 8 db.execute <>> 9 >>> 10 CREATE TABLE sites ( >>> 11 idx INTEGER PRIMARY KEY, >>> 12 url VARCHAR(255) >>> 13 ); >>> 14 >>> 15 SQL >>> >>> Thanks Jamis for helping me out!! >>> Ammon >>> >>> >>> On 11/3/05, Jamis Buck < jamis@37signals.com> wrote: On Nov 3, 2005, >>> at 9:47 AM, Ammon Christiansen wrote: >>> >>>> The require for sqlite3 returns false at the bottom. This is how I >>>> did my setup: >>>> >>>> I installed sqlite3 from source and installed the sqlite3-ruby gem >>>> using >>>> >>>> gem install sqlite3 -- --with-sqlite3-include=/fse/ajc55/sqlitebin/ >>>> include --with-sqlite3-lib=$HOME/sqlitebin/lib >>>> Select which gem to install for your platform (i686-linux) >>>> 1. sqlite3-ruby 1.1.0 (ruby) >>>> 2. sqlite3-ruby 1.1.0 (mswin32) >>>> 3. sqlite3-ruby 1.0.1 (ruby) >>>> 4. sqlite3-ruby 1.0.1 (mswin32) >>>> 5. sqlite3-ruby 1.0.0 (mswin32) >>>> 6. sqlite3-ruby 1.0.0 (ruby) >>>> 7. sqlite3-ruby 0.9.0 (ruby) >>>> 8. sqlite3-ruby 0.9.0 (mswin32) >>>> 9. sqlite3-ruby 0.6.0 (ruby) >>>> 10. sqlite3-ruby 0.5.0 (ruby) >>>> (I chose 1) >>>> with the following warnings: >>>> >>>> Successfully installed sqlite3-ruby-1.1.0 >>>> Installing RDoc documentation for sqlite3-ruby-1.1.0... >>>> >>>> lib/sqlite3/database.rb:637:65: Skipping require of dynamic string: >>>> "sqlite3/driver/#{ driver.to_s.downcase}/driver" >>>> >>>> lib/sqlite3/database.rb:642:59: Skipping require of dynamic string: >>>> "sqlite3/driver/#{d.downcase}/driver" >>>> >>>> I don't know what to make of the warnings and require 'sqlite3' >>>> returns false >>>> What does that mean? >>> >>> The warnings are just the rdoc generator saying it doesn't know how >>> to follow a dynamically generated string in order to parse the >>> referenced file. You can safely ignore those. (I really wish rdoc >>> didn't spew those messages out, but the current maintainer of rdoc >>> doesn't seem interested in doing anything with it.) >>> >>> Regarding "require 'sqlite3'" returning false, all it means is that >>> it has already been required elsewhere. When using rubygems (or irb), >>> I've noticed that require often returns false even if the file hasn't >>> been required elsewhere. Regardless, it's not an error condition. If >>> the file could not be required, an exception would have been raised. >>> >>> Are you having a problem running the program? Do you get an error? >>> (One thing I noticed in the program--you are referring to >>> SQLite::Database, but using the sqlite3 library. You ought to be >>> doing SQLite3::Database, in that case.) >>> >>> - Jamis >>> >>>> >>>> Here's the program >>>> 1 require 'rubygems' >>>> 2 require 'sqlite3' >>>> 3 #require 'sqlite3-ruby' >>>> 4 #require 'sqlite-ruby' >>>> 5 >>>> 6 db = SQLite::Database.new( 'sample.db', 0644 ) >>>> 7 >>>> 8 db.execute <>>> 9 >>>> 10 CREATE TABLE sites ( >>>> 11 idx INTEGER PRIMARY KEY, >>>> 12 url VARCHAR(255) >>>> 13 ); >>>> 14 >>>> 15 SQL >>>> >>> >>> >> >> > -a -- =============================================================================== | email :: ara [dot] t [dot] howard [at] noaa [dot] gov | phone :: 303.497.6469 | anything that contradicts experience and logic should be abandoned. | -- h.h. the 14th dalai lama ===============================================================================