On Tue, Mar 2, 2021 at 12:38 PM Immi <[email protected]> wrote:

> Hello all
>
> I'd like to change the journal mode on the Sqlite database that I'm
> connecting to.
> Looking at `connection_pragmas in the shared sqlite adapter, it doesn't
> seem to be supported though.
>
> Can I access the underlying Sqlite3 db object somehow and do it there
> directly? Is there a reason I'm not aware of why it isn't supported?
>
> For  reference, here's what I'm doing on the bare SQLite3 connection:
>
> SQLite3::Database.new("data.db") do |db|
>   db.foreign_keys = true
>   db.journal_mode = 'wal'
>   db.synchronous = 'normal'
>   db.locking_mode = 'normal'
>   db.auto_vacuum = 'incremental'
>   db.temp_store 'memory'
>
>   db.create_function('ulid', 0) do |func|
>     func.result = ULID.generate
>   end
> end
>

You can use the Database :after_connect option for this.  It is passed the
underlying SQLite3::Database object (if using the sqlite adapter), so the
block you had above will work:

Sequel.sqlite('data.db', :after_connect => do |db|
  # ...
end)

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 view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/CADGZSScazWtcWgcBnOD-fVPfhGi25aSM8p28VFuq4McQDi0nVw%40mail.gmail.com.

Reply via email to