[Haskell-cafe] ANN: Groundhog 0.3 - mysql, schemas and enhanced queries
lykahb at gmail.com
Fri Apr 19 10:42:14 CEST 2013
I am happy to announce release of Groundhog 0.3!
Groundhog is a library for high-level database access. It has support for
Sqlite, PostgreSQL, and a new MySQL backend. Advanced migration
capabilities allow you to precisely specify the schema description, fitting
it to an existing database, or creating a migration script for a new one.
Groundhog is not opinionated about schema and can bind your datatypes to a
relational model which may have composite keys, references across different
schemas, indexes, etc.
* Novel mechanism for defining your own functions, operators, or other
expressions and combining them in a type-safe manner. The operators LIKE
and IN, which appeared in this version, are one-liners based on it. Now you
can write advanced queries compositionally without resorting to raw SQL.
project (upper (ZipCodeField `append` AddressField), NumberField *
(NumberField + (1 :: Int))) $ lower NameField `like` "jack%"
will be transformed into SQL query
SELECT upper(zipcode || address), number * (number + ?) FROM tablename
WHERE lower(name) like ?
* PostgreSQL backend got support for arrays and geometric datatypes.
* First release of MySQL backend (influenced by persistent-mysql).
* New class ConnectionManager helps to extract connections from pools,
application state, or other sources. Now both plain connections and pools
can be run with the same function runDbConn. In particular, this class
helps with integrating Groundhog into web applications.
* Support for savepoints (nested transactions).
* Schema qualified tables. The entities can be configured with a schema
parameter. It defines schema where the table, its triggers, indexes, and
other related database objects are stored. Schemas are respected both
during migration and when generating queries.
* Custom primary keys. A unique set of fields can be defined as a
constraint, index, or primary key. Composite primary keys are supported as
* Configuration of reference clauses ON DELETE and ON UPDATE.
* New class SchemaAnalyzer exposes Groundhog functions for database
introspection. In future it can be used to build more powerful migration
tools, or generate datatypes from table definitions.
The full description of the configuration options is available at
Please see examples at
If you want to integrate Groundhog into your application which is based on
Snap, Yesod, or just uses another monad to store connections, see this
Although there are many new features in this release, Groundhog API is
mature enough to minimize the breaking changes. To migrate from Groundhog
2.* replace runSqliteConn/runPostgresqlConn/runSqlitePool/runPostgresqlPool
Special thanks to MightyByte who suggested to generalize connections and
helped to find the design, and to many others who gave their inspiring
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe