HORIZON HASKELLDocslts/ghc-10.0.x77a86622026-10-31Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 77a8662 · 2026-10-31

Modulepersistent-2.18.1.0Haskell2010

Database.Persist.SqlBackend

This module contains types and information necessary for a SQL database. Database support libraries, like persistent-postgresql, will be responsible for constructing these values.

Contents
  1. The type and construction
  2. Utilities
  3. SqlBackend Getters
  4. SqlBackend Setters
  5. SqlBackendHooks
Synopsis

The type and construction

datadata SqlBackend

A SqlBackend represents a handle or connection to a database. It contains functions and values that allow databases to have more optimized implementations, as well as references that benefit performance and sharing.

Instead of using the SqlBackend constructor directly, use the mkSqlBackend function.

A SqlBackend is *not* thread-safe. You should not assume that a SqlBackend can be shared among threads and run concurrent queries. This *will* result in problems. Instead, you should create a Pool SqlBackend, known as a ConnectionPool, and pass that around in multi-threaded applications.

To run actions in the persistent library, you should use the runSqlConn function. If you're using a multithreaded application, use the runSqlPool function.

Instances32PersistQueryRead, PersistQueryWrite, HasPersistBackend, IsPersistBackend, PersistCore, PersistStoreRead, …

This type shares many of the same field names as the SqlBackend type. It's useful for library authors to use this when migrating from using the SqlBackend constructor directly to the mkSqlBackend function.

This type will only contain required fields for constructing a SqlBackend. For fields that aren't present on this record, you'll want to use the various set functions or

Constructors

Utilities

The functions exported here are a bit more general than the record accessors. The easiest way to use them is to provide the SqlBackend directly to the function. However, you can also use them in a ReaderT context, and you can even use them with any backend type tht has a BackendCompatible SqlBackend backend instance.

SqlBackend Getters

SqlBackend Setters

SqlBackendHooks