[Haskell-cafe] [ANN] mysql-simple - your go-to package for talking to MySQL

Bryan O'Sullivan bos at serpentine.com
Mon May 2 05:13:12 CEST 2011


Hi, folks -

Over the past few days, I've released two MySQL-related packages on Hackage
that I think should be pretty useful.

The first is mysql-simple: http://hackage.haskell.org/package/mysql-simple

This is a mid-level binding to the MySQL client API. I aimed it squarely at
being both fast and easy to use, and I'm very pleased with the results so
far.

   - Performance: compared to HDBC-mysql, mysql-simple yields a 60%
   performance improvement on my real-world application.
   - Ease of use: compared again to HDBC, my real-world application's
   DB-specific code shrunk by 50% while achieving the above performance
   increase.
   - Type safety: it's intentionally hard to construct SQL queries by string
   concatenation, but of course I provide some nice safe APIs for formatting
   queries and converting results. That safety does not come at the expense of
   performance or expressive bloat, as the above results indicate.

Because I know that some people favour interacting with their databases via
a model such as iteratees, the mysql-simple library is built on top of a
very lightweight library.

That lower-level library is named mysql:
http://hackage.haskell.org/package/mysql

This is a low-level binding to the MySQL client API. It is aimed at high
performance and simplicity, but more specifically for consumption by authors
of higher-level database libraries. It is bare enough of features that it
doesn't even perform conversion between Haskell and SQL types, but at the
same time it uses bytestrings sensibly, cheaply avoids some nasty signal
interruption problems with the MySQL client library, and abstracts some of
the tiresome details of memory management. It gives a higher-level library
complete control over result conversion, how to fetch results, and all that,
so you can focus purely on building iteratees and not the lower-level gunk.

Enjoy!
B.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110501/bcdb3f3c/attachment.htm>


More information about the Haskell-Cafe mailing list