wai-session-hasql: A wai-session store using Hasql and PostgreSQL

[ bsd3, library, web ] [ Propose Tags ] [ Report a vulnerability ]

Provides PostgreSQL as wai-session store, and using Hasql as the PostgreSQL connector. It supports both single Hasql connection and Hasql pool connection.


[Skip to Readme]

Modules

[Index] [Quick Jump]

Flags

Manual Flags

NameDescriptionDefault
build-example

Build the example executable

Disabled

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 1.0.0.0
Change log CHANGELOG.md
Dependencies aeson (>=2.0 && <2.4), base (>=4.16.0.0 && <5), bytestring (>=0.10 && <0.13), cookie (>=0.5 && <0.6), hasql (>=2.0 && <2.1), hasql-pool (>=1.5 && <1.6), http-types (>=0.12 && <0.13), mmzk-typeid (>=0.7 && <0.8), pqi-native (>=1.0 && <1.1), text (>=1.2 && <3), time (>=1.9 && <1.17), uuid (>=1.3 && <1.4), vault (>=0.3 && <0.4), wai (>=3.2 && <3.3), wai-session (>=0.3 && <0.4), wai-session-hasql, warp (>=3.4 && <3.5) [details]
Tested with ghc ==9.12.2
License BSD-3-Clause
Author Haoxiang Zhao
Maintainer haoxiangz201@gmail.com
Uploaded by block81838 at 2026-09-16T14:34:51Z
Category Web
Home page https://github.com/Block81838/WAI-Session-Hasql
Bug tracker https://github.com/Block81838/WAI-Session-Hasql/issues
Source repo head: git clone https://github.com/Block81838/WAI-Session-Hasql.git
Distributions
Executables wai-session-hasql-example
Downloads 0 total (0 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for wai-session-hasql-1.0.0.0

[back to package description]

wai-session-hasql

A wai-session store that using PostgreSQL as backend, and hasql as db connector.

It supports both single hasql connection and hasql pool connection.

Basic usage, see example/Main.hs for a complete example. You will need to replace the connection string with your own PostgreSQL connection string in the example and tests files.

main :: IO ()
main = do
  -- Create a vault key
  k <- newKey :: IO (Key (Network.Wai.Session.Session IO T.Text Aeson.Value))
  -- Init Hasql connection pool
  pool <- P.acquire adapter (settings [size 10, staticConnectionSettings (connectionString "postgres://dbadmin:P%40ssw0rd@localhost:5432/appdb")])
  s <- hasqlStore (SessionSetting (HasqlPool pool) True (60 * 60 * 24) False)
  -- Create the wai-session middleware by using withSession function
  let sm = withSession s (B8.pack "hello") defaultSetCookie k
      asess = sm $ app k
  run 3000 asess