Skip to content

Commit

Permalink
Allow opening with flags + bump version to 0.4.19.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
KtorZ committed Feb 6, 2024
1 parent fd9355d commit 08015be
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
13 changes: 13 additions & 0 deletions Database/SQLite/Simple.hs
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,16 @@ module Database.SQLite.Simple (
, Only(..)
, (:.)(..)
, Base.SQLData(..)
, Base.SQLOpenFlag(..)
, Statement(..)
, ColumnIndex(..)
, NamedParam(..)
-- * Connections
, open
, open'
, close
, withConnection
, withConnection'
, setTrace
-- * Queries that return results
, query
Expand Down Expand Up @@ -168,6 +171,12 @@ instance Exception FormatError
open :: String -> IO Connection
open fname = Connection <$> Base.open (T.pack fname) <*> newIORef 0

-- | Similar to 'open' but allows specifying opening flags.
open' :: String -> [Base.SQLOpenFlag] -> IO Connection
open' fname flags = Connection
<$> Base.open2 (T.pack fname) flags Base.SQLVFSDefault
<*> newIORef 0

-- | Close a database connection.
close :: Connection -> IO ()
close = Base.close . connectionHandle
Expand All @@ -177,6 +186,10 @@ close = Base.close . connectionHandle
withConnection :: String -> (Connection -> IO a) -> IO a
withConnection connString = bracket (open connString) close

-- | Opens a database connection with flags. Similar to 'withConnection'.
withConnection' :: String -> [Base.SQLOpenFlag] -> (Connection -> IO a) -> IO a
withConnection' connString flags = bracket (open' connString flags) close

unUtf8 :: BaseD.Utf8 -> T.Text
unUtf8 (BaseD.Utf8 bs) = TE.decodeUtf8 bs

Expand Down
6 changes: 6 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
packages: .

source-repository-package
type: git
location: https://github.com/CardanoSolutions/direct-sqlite
tag: 2b14a78cb73805e2e5d84354230e872a223faa39
4 changes: 2 additions & 2 deletions sqlite-simple.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Name: sqlite-simple
Version: 0.4.19.0
Version: 0.4.19.0.1
Synopsis: Mid-Level SQLite client library
Description:
Mid-level SQLite client library, based on postgresql-simple.
Expand Down Expand Up @@ -51,7 +51,7 @@ Library
blaze-textual,
bytestring >= 0.9,
containers,
direct-sqlite >= 2.3.13 && < 2.4,
direct-sqlite == 2.3.29.1,
exceptions >= 0.4,
template-haskell,
text >= 0.11,
Expand Down

0 comments on commit 08015be

Please sign in to comment.