HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulepersistent-sqlite-2.13.3.0Haskell2010

Database.Sqlite

A port of the direct-sqlite package for dealing directly with PersistValues.

  • 9 types
  • 25 values
datadata Connection
#

SQLite connection type, consist of an IORef tracking whether the connection has been closed and the raw SQLite C API pointer, wrapped in a 'Connection'' newtype.

newtypenewtype Statement
#

Newtype wrapping SQLite C API pointer for a prepared statement.

datadata Error
#
Instances2Eq, Show
  • Eq ErrorDefined in persistent-sqlite-2.13.3.0 · Database.Sqlite
  • Show ErrorDefined in persistent-sqlite-2.13.3.0 · Database.Sqlite
datadata SqliteStatusVerb
#

Run-time status parameter that can be returned by status function.

Constructors

  • SqliteStatusMemoryUsed

    This parameter is the current amount of memory checked out using sqlite3_malloc(), either directly or indirectly. The figure includes calls made to sqlite3_malloc() by the application and internal memory usage by the SQLite library. Scratch memory controlled by SQLITE_CONFIG_SCRATCH and auxiliary page-cache memory controlled by SQLITE_CONFIG_PAGECACHE is not included in this parameter. The amount returned is the sum of the allocation sizes as reported by the xSize method in sqlite3_mem_methods.

  • SqliteStatusPagecacheUsed

    This parameter returns the number of pages used out of the pagecache memory allocator that was configured using SQLITE_CONFIG_PAGECACHE. The value returned is in pages, not in bytes.

  • SqliteStatusPagecacheOverflow

    This parameter returns the number of bytes of page cache allocation which could not be satisfied by the SQLITE_CONFIG_PAGECACHE buffer and where forced to overflow to sqlite3_malloc(). The returned value includes allocations that overflowed because they where too large (they were larger than the "sz" parameter to SQLITE_CONFIG_PAGECACHE) and allocations that overflowed because no space was left in the page cache.

  • SqliteStatusScratchUsed

    This parameter returns the number of allocations used out of the scratch memory allocator configured using SQLITE_CONFIG_SCRATCH. The value returned is in allocations, not in bytes. Since a single thread may only have one scratch allocation outstanding at time, this parameter also reports the number of threads using scratch memory at the same time.

  • SqliteStatusScratchOverflow

    This parameter returns the number of bytes of scratch memory allocation which could not be satisfied by the SQLITE_CONFIG_SCRATCH buffer and where forced to overflow to sqlite3_malloc(). The values returned include overflows because the requested allocation was too larger (that is, because the requested allocation was larger than the "sz" parameter to SQLITE_CONFIG_SCRATCH) and because no scratch buffer slots were available.

  • SqliteStatusMallocSize

    This parameter records the largest memory allocation request handed to sqlite3_malloc() or sqlite3_realloc() (or their internal equivalents). Only the value returned in sqliteStatusHighwater field of SqliteStatus record is of interest. The value written into the sqliteStatusCurrent field is Nothing.

  • SqliteStatusPagecacheSize

    This parameter records the largest memory allocation request handed to pagecache memory allocator. Only the value returned in the sqliteStatusHighwater field of SqliteStatus record is of interest. The value written into the sqliteStatusCurrent field is Nothing.

  • SqliteStatusScratchSize

    This parameter records the largest memory allocation request handed to scratch memory allocator. Only the value returned in the sqliteStatusHighwater field of SqliteStatus record is of interest. The value written into the sqliteStatusCurrent field is Nothing.

  • SqliteStatusMallocCount

    This parameter records the number of separate memory allocations currently checked out.

Basic usage guide

25 declarations

Note that the example code shown here is a low level interface usage. Let's create a small demo sqlite3 database which we will use in our program:

$ sqlite3 ~/test.db
sqlite> create table t1(a,b);
sqlite> insert into t1(a,b) values (1,1);
sqlite> insert into t1(a,b) values (2,2);
sqlite> select * from t1;
1|1
2|2

Now let's write code using the functions in this module to fetch the rows from the table:

{-#LANGUAGE OverloadedStrings#-}

import Database.Sqlite
import Data.Text

main :: IO ()
main = do
  conn <- open "/home/sibi/test.db"
  smt <- prepare conn "select * from t1;"
  row1 <- step smt >> columns smt
  row2 <- step smt >> columns smt
  print (row1, row2)
  finalize smt
  close conn

On executing the above code:

$ ./demo-program
$ ([PersistInt64 1,PersistInt64 1],[PersistInt64 2,PersistInt64 2])
valueconfig :: Config -> IO ()
#

Sets SQLite global configuration parameter. See SQLite documentation for the sqlite3_config function. In short, this must be called prior to any other SQLite function if you want the call to succeed.

Retrieves runtime status information about the performance of SQLite, and optionally resets various highwater marks. The first argument is a status parameter to measure, the second is reset flag. If reset flag is True then the highest recorded value is reset after being returned from this function.

valuesoftHeapLimit :: Int64 -> IO Int64
#

Sets and/or queries the soft limit on the amount of heap memory that may be allocated by SQLite. If the argument is zero then the soft heap limit is disabled. If the argument is negative then no change is made to the soft heap limit. Hence, the current size of the soft heap limit can be determined by invoking this function with a negative argument.