On Tuesday, February 14, 2017 at 12:46:13 PM UTC-8, Chris Riddoch wrote:
>
> What's the recommended technique for calling (for example) 
> SQLite3::Database#create_function or #create_aggregate given that I've 
> opened a database with the conventional DB = Sequel.sqlite(path)?
>
> I'm thinking of making an extension that would expose and use these 
> callbacks, but I'm not sure how to call methods on the SQLite3::Database 
> object from a Sequel::SQLite3::Database object.
>

These appear to be methods on the connection object, so the only safe place 
to call them would be in an after_connect proc.  If you are adding this via 
an external extension, you would need to do:

pr = db.pool.after_connect
db.pool.after_connect = proc do |c|
  pr.call(c) if pr
  c.create_function(...)
  c.create_aggregate(...)
end
db.disconnect  # to generate new connections with the functions/aggregates 
loaded

where db is the Sequel::Database instance you are loading the extension 
into.

Thanks,
Jeremy 

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to