Ryan Davis wrote:
> 
> Eric was referring to your python code:
> 
>>  DB.execute('SELECT load_extension("libspatialite.so")');
> 
> that's a plain DB execute with a select statement to load spatialite.
> You should be doing almost the same thing on the ruby side. The rest
> of the code will prolly Just Work (or at least be much closer) after
> that.

Next try:

#!/usr/bin/env ruby

require 'rubygems'
  require 'sqlite3'
  db = SQLite3::Database.new( "exif.sqlite" )

#Does NOT work:
   db.execute('SELECT load_extension("libspatialite.so")');
   db.execute( "SELECT DateTime(GpsTimestamp), FromPath FROM ExifPhoto" 
) do |row|
    p row
  end

  db.close

Does anyone know how to enable the sqlite extension mechanism from ruby?
It seems it's switched off by default for security reasons.

Error I get with the code above:

ruby test.rb
/home/me/.gem/ruby/1.8/gems/sqlite3-ruby-1.2.4/lib/sqlite3/errors.rb:62:in 
`check': not authorized (SQLite3::SQLException)
  from 
/home/me/.gem/ruby/1.8/gems/sqlite3-ruby-1.2.4/lib/sqlite3/resultset.rb:56:in 
`check'
  from 
/home/me/.gem/ruby/1.8/gems/sqlite3-ruby-1.2.4/lib/sqlite3/resultset.rb:48:in 
`commence'
  from 
/home/me/.gem/ruby/1.8/gems/sqlite3-ruby-1.2.4/lib/sqlite3/resultset.rb:38:in 
`initialize'
  from 
/home/me/.gem/ruby/1.8/gems/sqlite3-ruby-1.2.4/lib/sqlite3/statement.rb:135:in 
`new'
  from 
/home/me/.gem/ruby/1.8/gems/sqlite3-ruby-1.2.4/lib/sqlite3/statement.rb:135:in 
`execute'
  from 
/home/me/.gem/ruby/1.8/gems/sqlite3-ruby-1.2.4/lib/sqlite3/database.rb:182:in 
`execute'
  from 
/home/me/.gem/ruby/1.8/gems/sqlite3-ruby-1.2.4/lib/sqlite3/database.rb:157:in 
`prepare'
  from 
/home/me/.gem/ruby/1.8/gems/sqlite3-ruby-1.2.4/lib/sqlite3/database.rb:181:in 
`execute'
  from test.rb:8


-- 
Posted via http://www.ruby-forum.com/.