https://github.com/cocreature/postgresql-named
Deserialize PostgreSQL rows to Haskell records by matching column names and record field names
https://github.com/cocreature/postgresql-named
haskell postgresql
Last synced: 4 months ago
JSON representation
Deserialize PostgreSQL rows to Haskell records by matching column names and record field names
- Host: GitHub
- URL: https://github.com/cocreature/postgresql-named
- Owner: cocreature
- License: bsd-3-clause
- Created: 2017-06-12T18:19:42.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2018-02-19T17:20:20.000Z (over 8 years ago)
- Last Synced: 2025-03-23T20:43:26.834Z (over 1 year ago)
- Topics: haskell, postgresql
- Language: Haskell
- Homepage:
- Size: 16.6 KB
- Stars: 13
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# postgresql-named
[](https://travis-ci.org/cocreature/postgresql-named)
[](https://hackage.haskell.org/package/postgresql-named)
Library for deserializing rows in `postgresql-simple` (or any other
library that uses `FromRow`) based on column names instead of the
positions of columns.
## Example
```haskell
{-# LANGUAGE DeriveGeneric #-}
import Database.PostgreSQL.Simple.FromRow
import Database.PostgreSQL.Simple.FromRow.Named
import qualified GHC.Generics as GHC
import Generics.SOP
data Foobar = Foobar
{ foo :: !String
, bar :: !Int
} deriving (Show, Eq, Ord, GHC.Generic)
instance Generic Foobar
instance HasDatatypeInfo Foobar
instance FromRow Foobar where
fromRow = gFromRow
```