Skip to content

Commit

Permalink
Add Database.Persist.Sqlite.createSqlitePoolWithConfig (#1524)
Browse files Browse the repository at this point in the history
* Add Database.Persist.Sqlite.createSqlitePoolWithConfig

* Update the Changelog.md file with a link to PR

* Bump the version number from 2.13.2.0 to 2.13.4.0

---------

Co-authored-by: Matt von Hagen (Parsons) <parsonsmatt@gmail.com>
  • Loading branch information
ciukstar and parsonsmatt committed Dec 7, 2023
1 parent e2fb8d4 commit 213e904
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions persistent-sqlite/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## 2.13.3.0 (unreleased)

* [#1524](https://github.com/yesodweb/persistent/pull/1524)
* Add Database.Persist.Sqlite.createSqlitePoolWithConfig to create a SQLite
connection pool with a connection string and ConnectionPoolConfig.
Using ConnectionPoolConfig, it is possible to set the connection idle timeout.
* [#1486](https://github.com/yesodweb/persistent/pull/1486)
* Add Database.Sqlite.open' which takes a ByteString
* [#1522](https://github.com/yesodweb/persistent/pull/1522)
Expand Down
10 changes: 10 additions & 0 deletions persistent-sqlite/Database/Persist/Sqlite.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ module Database.Persist.Sqlite
, withSqliteConnInfo
, createSqlitePool
, createSqlitePoolFromInfo
, createSqlitePoolWithConfig
, module Database.Persist.Sql
, SqliteConf (..)
, SqliteConnectionInfo
Expand Down Expand Up @@ -133,6 +134,15 @@ createSqlitePoolFromInfo :: (MonadLoggerIO m, MonadUnliftIO m)
=> SqliteConnectionInfo -> Int -> m (Pool SqlBackend)
createSqlitePoolFromInfo connInfo = createSqlPool $ openWith const connInfo

-- | Create a pool of SQLite connections.
--
-- @since 2.13.4.0
createSqlitePoolWithConfig :: (MonadUnliftIO m, MonadLoggerIO m)
=> Text -- ^ connection string
-> ConnectionPoolConfig -> m (Pool SqlBackend)
createSqlitePoolWithConfig connString =
createSqlPoolWithConfig (openWith const (conStringToInfo connString))

-- | Run the given action with a connection pool.
--
-- Like 'createSqlitePool', this should not be used with @:memory:@.
Expand Down

0 comments on commit 213e904

Please sign in to comment.