{"repo":"parsonsmatt/persistent-typed-db","free":true,"listed":false,"github":"https://github.com/parsonsmatt/persistent-typed-db","clone":"git clone https://github.com/parsonsmatt/persistent-typed-db.git","description":"A type and helpers for typesafe SQL access in the presence of many databases.","language":"Haskell","stars":23,"topics":["database","haskell","persistent"],"license":"BSD-3-Clause","category":"databases-storage","readme_excerpt":"persistent-typed-db This library defines an alternate SqlBackend type for the Haskell persistent database library. The type has a phantom type parameter which allows you to write queries against multiple databases safely. The Problem The persistent library uses a \"handle pattern\" with the SqlBackend type. The SqlBackend (or Pool SqlBackend ) is used to provide access to \"The Database.\" To access the database, you generally use a function like: However, you may have two (or more!) databases. You might have multiple database \"runner\" functions, like this: Unfortunately, this isn't safe. The schemas differ, and there's nothing preventing you from using the wrong runner for the query at hand. This library allows you to differentiate between database schemata. To demonstrate usage, we'll start with a pair of ordinary persistent quasiquoter blocks: These two definitions correspond to different databases. The persistent library uses the SqlPersistT m monad transformer for queries. This type is a synonym for ReaderT SqlBackend m . Many of the functions defined in persistent have a signature like this: It requires that the entity is compatible with the query monad. We're going to substitute User for the type variable record . In the initial schema definition, the PersistEntityBackend User is defined as SqlBackend . So the type of get , in the original definition, is this: If we look at the type of get specialized to AuxRecord , we see this: This means that we might be able to write a ","default_branch":null,"files":null,"tree":[],"storefront":"/r/parsonsmatt","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/parsonsmatt/persistent-typed-db/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}