esqueleto-pgcrypto: Esqueleto support for the pgcrypto PostgreSQL module

[ bsd3, database, library ] [ Propose Tags ]


[Index] [Quick Jump]


Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


  • No Candidates
Versions [RSS]
Change log
Dependencies base (>=4.13 && <5), esqueleto (>= && <3.6), text (>= && <1.3) [details]
License BSD-3-Clause
Copyright 2021 Kyriakos Papachrysanthou
Author Kyriakos Papachrysanthou
Category Database
Home page
Bug tracker
Source repo head: git clone
Uploaded by 3kyro at 2021-10-06T12:07:01Z
Downloads 126 total (4 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
All reported builds failed as of 2021-10-06 [all 1 reports]

Readme for esqueleto-pgcrypto-

[back to package description]


Esqueleto support for the pgcrypto PostgreSQL module

    [mkPersist sqlSettings]
    UserAccount json
        name T.Text
        UniqueName name
        passwordHash T.Text
        deriving Show Read Eq

-- insert a `PersistField` using pgcrypto's `crypt` function for password hashing
insertUserAccount = insertSelect $ 
    pure $
            <# val "username"
            <&> toCrypt (BF Nothing) "1234password"

login name pwd = select $ do
    user <- from $ Table UserAccount
    where_ $ user ^. UserAccountName ==. val name
        &&. fromCrypt (user ^. UserAccountPasswordHash) pwd
    pure user


To run tests you will need a pgctest named postgresql database listening on port 5432.

The connection details are

"host=localhost port=5432 user=pgctest password=pgctest dbname=pgctest"

You can crete this instace as follows:

$ sudo -u postgres createuser --superuser pgctest 
$ sudo -u postgres createdb pgctest
$ sudo -u postgres psql
# set the password of pgctest to pgctest
postgres=# \password pgctest