{"id":18324703,"url":"https://github.com/tchoutri/pg-entity","last_synced_at":"2026-03-16T10:33:01.349Z","repository":{"id":38256808,"uuid":"343219705","full_name":"tchoutri/pg-entity","owner":"tchoutri","description":"A pleasant PostgreSQL database layer for Haskell","archived":false,"fork":false,"pushed_at":"2024-10-28T10:47:15.000Z","size":637,"stargazers_count":42,"open_issues_count":3,"forks_count":8,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-21T13:53:12.987Z","etag":null,"topics":["database-layer","haskell","postgresql","simple-haskell","sql"],"latest_commit_sha":null,"homepage":"https://hackage.haskell.org/package/pg-entity/src/docs/book/index.html","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tchoutri.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-02-28T21:33:08.000Z","updated_at":"2024-11-10T20:49:48.000Z","dependencies_parsed_at":"2023-02-14T10:00:28.629Z","dependency_job_id":"f36765d5-c590-4701-818e-082c7cd3fa9e","html_url":"https://github.com/tchoutri/pg-entity","commit_stats":{"total_commits":120,"total_committers":8,"mean_commits":15.0,"dds":0.09166666666666667,"last_synced_commit":"e967de05359e72dc12ca623d0ea008b851499f5d"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tchoutri%2Fpg-entity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tchoutri%2Fpg-entity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tchoutri%2Fpg-entity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tchoutri%2Fpg-entity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tchoutri","download_url":"https://codeload.github.com/tchoutri/pg-entity/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247419597,"owners_count":20936009,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database-layer","haskell","postgresql","simple-haskell","sql"],"created_at":"2024-11-05T18:35:34.516Z","updated_at":"2026-03-16T10:33:01.308Z","avatar_url":"https://github.com/tchoutri.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n  pg-entity\n\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://github.com/tchoutri/pg-entity/actions\"\u003e\n  \u003cimg src=\"https://img.shields.io/github/actions/workflow/status/tchoutri/pg-entity/ci.yml?style=flat-square\" alt=\"CI badge\" /\u003e\n\u003c/a\u003e\n\u003ca href=\"https://haskell.org\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/Made%20in-Haskell-%235e5086?logo=haskell\u0026style=flat-square\" alt=\"made with Haskell\"/\u003e\n\u003c/a\u003e\n\u003ca href=\"https://hackage.haskell.org/package/pg-entity\"\u003e\n  \u003cimg src=\"https://img.shields.io/hackage/v/pg-entity?style=flat-square\" alt=\"Hackage\" /\u003e\n\u003c/a\u003e\n\u003c/p\u003e\n\nThis library is a pleasant layer on top of [postgresql-simple][pg-simple] to safely expand the fields of a table when\nwriting SQL queries.  \nIt aims to be a convenient middle-ground between rigid ORMs and hand-rolled SQL query strings. Here is its philosophy:\n\n* The serialisation/deserialisation part is left to the consumer, so you have to go with your own FromRow/ToRow instances.\n  You are encouraged to adopt data types in your application that model your business domain, rather than restrict yourself within the limits of what\n  an SQL schema can represent. Use an intermediate Data Access Object (DAO) that can easily be serialised and deserialised\n  to and from a SQL schema, to and from which you will morph your business data-types.\n* Illegal states are made harder (but not impossible) to represent. Generic deriving of entities is encouraged, and\n  quasi-quoters are provided to denote fields in a safer way. \n* Escape hatches are provided at every level. The types that are manipulated are Query for which an `IsString` instance exists.\n  Don't force yourself to use the higher-level API if the lower-level combinators work for you, and if those don't either, “Just Write SQL”™.\n\nIts dependency footprint is optimised for my own setups, and as such it makes use of [text][text], [vector][vector] and\n[pg-transact][pg-transact].\n\n\n\nTable of Contents\n=================\n\n* [Documentation](#documentation)\n  * [Escape hatches](#escape-hatches)\n* [Acknowledgements](#acknowledgements)\n\n## Documentation\n\n* [Tutorial][docs-url]\n\nThis library aims to be thoroughly tested, by the means of Oleg Grenrus' [cabal-docspec][docspec]\nand more traditional tests for database roundtrips.\n\nI aim to produce and maintain a decent documentation, therefore do not hesitate to raise an issue if you feel that\nsomething is badly explained and should be improved.\n\n\n### Escape hatches\n\nSafe SQL generation is a complex subject, and it is far from being the objective of this library. The main topic it\naddresses is listing the fields of a table, which is definitely something easier. This is why every level of this wrapper\nis fully exposed, so that you can drop down a level at your convience.\n\nIt is my personal belief, firmly rooted in experience, that we should not aim to produce statically-checked SQL and have\nit \"verified\" by the compiler. The techniques that would allow that in Haskell are still far from being optimised and\nergonomic. As such, this library makes no effort to produce semantically valid SQL queries, because one would have to\nencode the semantics of SQL in the type system (or in a rule engine of some sort), and this is clearly not the kind of\nthings I want to spend my youth on.\n\nEach function is tested for its output with doctests, and the ones that cannot (due to database connections) are tested\nin the more traditional test-suite.\n\nThe conclusion is : Test your DB queries. Test the encoding/decoding. Make roundtrip tests for your data-structures.\n\n## Acknowledgements \n\nI wish to thank\n\n* Clément Delafargue, whose [anorm-pg-entity][anorm-pg-entity] library and its [initial port in Haskell][entity-blogpost-fretlink]\n  are the spiritual parents of this library\n* Koz Ross, for his piercing eyes and his immense patience\n* Joe Kachmar, who enlightened me many times\n\n[docs]: https://img.shields.io/badge/Tutorial%20and%20Guides-pg--entity-blueviolet\n[docs-url]: https://hackage.haskell.org/package/pg-entity/src/docs/book/index.html\n[docspec]: https://github.com/phadej/cabal-extras/blob/master/cabal-docspec/MANUAL.md\n[pg-transact-hspec]: https://github.com/jfischoff/pg-transact-hspec.git\n[entity-blogpost-fretlink]: https://blog.clement.delafargue.name/posts/2020-09-23-yet-another-unsafe-db-layer.html\n[anorm-pg-entity]: https://github.com/CleverCloud/anorm-pg-entity\n[pg-simple]: https://hackage.haskell.org/package/postgresql-simple\n[pg-transact]: https://hackage.haskell.org/package/pg-transact\n[text]: https://hackage.haskell.org/package/text\n[vector]: https://hackage.haskell.org/package/vector\n[CI-badge]: https://img.shields.io/github/workflow/status/tchoutri/pg-entity/CI?style=flat-square\n[CI-url]: https://github.com/tchoutri/pg-entity/actions\n[simple-haskell]: https://img.shields.io/badge/Simple-Haskell-purple?style=flat-square\n[BlogPost-module]: https://github.com/tchoutri/pg-entity/blob/main/src/Database/PostgreSQL/Entity/Internal/BlogPost.hs\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftchoutri%2Fpg-entity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftchoutri%2Fpg-entity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftchoutri%2Fpg-entity/lists"}