From: Jamis Buck Date: 2004-05-12T01:55:22+09:00 Subject: [ANN] SQLite/Ruby 1.1 SQLite/Ruby version 1.1 is now available. http://sqlite-ruby.rubyforge.org It has moved from SourceForge to RubyForge (thanks, Tom!) and has a few new features: 1) The "show_datatypes" pragma now works. If you enable it, then the "row" object that gets passed to the associated block will have a property called "column_types". This is a hash that allows you to get the type of a particular column in the query, either by name or by index. db.show_datatypes = true db.execute( "select a, b, c from my_table" ) do |row| p row.column_types p row end If show_datatypes is not enabled, then the row object will not have the column_types property. 2) The "empty_result_callbacks" pragma should work now. It used to cause a segfault. 3) Type conversion is now available. This allows you to select from a SQLite database and have the result set translated to the appropriate Ruby types. It is even possible (but not yet documented) to define your own type-conversion routines, which should (theoretically) allow you to do things like persist objects in a SQLite database. (Haven't tried that, but it sounds cool, huh?) The show_datatypes pragma must be enabled for type conversion to work. db.show_datatypes = true db.type_translation = true db.execute( "select a, b, c from my_table" ) do |row| p row.column_types p row end 4) Two new convenience methods have been added to make singleton selects easier (thanks, Carl!). SQLite::Database#get_first_row(sql) returns the first row that the given query returns. SQLite::Database#get_first_value(sql) returns the first column of the first row that the given query returns. In addition, the error handling should be a little more robust. AND--there is a gem version of it! Not precompiled, unfortunately, but thanks to the hard working RubyGems team, you can now use RubyGems to download and compile binary gems for you. :) It works for this gem, anyway, under Linux. You'll need to have SQLite itself already installed, though, whether you go with the gem installation or the manual one. And if Chad or Richard could please add the gem file for this to their gem repository, you will all be able to just do a remote gem install. It doesn't get any better than that, folks. :) -- Jamis Buck jgb3@email.byu.edu http://www.jamisbuck.org/jamis ruby -h | ruby -e 'a=[];readlines.join.scan(/-(.)\[e|Kk(\S*)|le.l(..)e|#!(\S*)/) {|r| a << r.compact.first };puts "\n>#{a.join(%q/ /)}<\n\n"'