On Tuesday, January 8, 2013 2:09:02 PM UTC-8, James wrote:
>
> Hi,
>
> Is it possible to enable and load SQLite extensions from Sequel, or access 
> the underlying adapter class/methods?  Here's an example of what is 
> provided by sqlite3-ruby:
>
> https://github.com/luislavena/sqlite3-ruby/issues/39
>
> I was hoping to use extension-functions.c listed on the sqlite.orgcontrib 
> page (includes math functions useful for distance calculation):
>
> http://www.sqlite.org/contrib
>

You can get direct access to the underlying connection via 
Database#synchronize:

  DB.synchronize do |conn|

    conn.enable_load_extension(1)    
conn.load_extension("/usr/local/lib/extension.dylib")    
conn.enable_load_extension(0)

  end

For a single threaded app, that's probably fine.  Note that for a 
multi-threaded app, you would probably want to use an after_connect proc:

  DB = Sequel.connect(..., :after_connect=>(proc do |conn|

    conn.enable_load_extension(1)    
conn.load_extension("/usr/local/lib/extension.dylib")    
conn.enable_load_extension(0)

  end))

Thanks,
Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sequel-talk/-/pXGGRpJ14VsJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en.

Reply via email to