crawshaw / sqlite

Go SQLite3 driver
ISC License
561 stars 67 forks source link

Add sqlitex.OpenInit to allow initializing all Conns in a Pool with a script #128

Closed AdamSLevy closed 2 years ago

AdamSLevy commented 2 years ago

Many settings need to be set for all Conns every time they are opened. Some examples are per connection PRAGMAs or running CREATE VIEW. This is a tad cumbersome to do for all connections in a Pool.

This sqlitex.OpenInit adds the ability to provide an initScript to be run on all Conns when opening a pool. A context.Context can be provided so that a timeout on the initScript can be enforced.

Now sqlitex.Open is a wrapper of sqlitex.OpenInit with an empty script and nil context.

fix #101

AdamSLevy commented 2 years ago

@anacrolix I welcome your code review if you have the time. I'll merge next week if not.

mitar commented 6 months ago

Sadly this cannot be used for connection.Limit. :-(