ANNOUNCE: HaskellDB 2.0: Scrap your SQL strings

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

ANNOUNCE: HaskellDB 2.0: Scrap your SQL strings

Justin Bailey
What is it?
========

The HaskellDB library lets you generate SQL queries without writing
any actual SQL. Unlike other query generating libraries, you choose
the abstraction level. Queries can be built out of independent
fragments, just like your programs. Leave hand-written, string-based,
SQL libraries behind and check out HaskellDB.

Where to get it?
============

You can get it  from Hackage
(http://hackage.haskell.org/package/haskelldb) or by using cabal
(cabal install haskelldb).

You also need drivers for your specific database. HaskellDB currently
supports the HDBC family of drivers. First, download haskelldb-hdbc
(http://hackage.haskell.org/package/haskelldb-hdbc), then get the
appropriate package  for your database:

  * ODBC: haskelldb-hdbc-odbc
(http://hackage.haskell.org/package/haskelldb-hdbc-odbc)
  * Postgres: haskelldb-hdbc-postgresql
(http://hackage.haskell.org/package/haskelldb-hdbc-postgresql)
  * Sqllite: haskelldb-hdbc-sqlite3
(http://hackage.haskell.org/package/haskelldb-hdbc-sqlite3)

Documentation, Mailing List, Source, etc
=======================

Go to http://trac.haskell.org/haskelldb for detailed information.

What's New?
=========

  * New query capabilities: stored procedures, CASTs, query
parameters, constants, and more.
  * Postgres SQL improvements.
  * Bug fixes around AND and OR associativity.
  * Query optimization improvements around aggregate expressions.
  * More tests.

Details
=====

Back in June 2009, Bjorn Bringert passed maintainership of HaskellDB
to me. I've been working this summer to get a release out, which
included:

  * Adding an examples/ directory to the source distribution.
  * Archiving and consolidating information to
http://trac.haskell.org/haskelldb.
  * Accepting patches for various issues.

I have used a lot of ORM & SQL-wrapper libraries during my career and
HaskellDB is the first that I've found which does not require you to
eventually break the abstraction.

Learning to use the the library was a fun challenge but not one that
many people are willing to take, when they can easily write SQL by
hand. If the library was easier to get started with, I think it would
be much more widely used. Help me get HaskellDB better documentation!

If you are using HaskellDB and want to help: go to
http://trac.haskell.org/haskelldb and write an article, write a blog
post, get in touch with me, etc. When I saw that Rails 3.0 uses the
"ARel" gem (based on the relational algebra) I groaned - Haskell has
had that forever! We need to get the word out!

Why 2.0?
--------------

Last year Brian Bloniarz contributed an awesome patch which replaced
HaskellDB's home-grown record system with the HList library by Oleg
Kiselyov (and colleagues). I intended to work with the library for
awhile and get a 1.0 release out.

Unfortunately, HList proved too daunting for GHC and for me. Compile
times went way up, and I could not isolate it enough to give GHC HQ a
repro case. Even worse, HList required too many Oleg units for me to
comprehend. I could usually fix compile errors, but found myself
struggling to extend HaskellDB's functionality. In the end I felt I
needed to back the patch out. I really hated to lose some of the
functionality but in the end maintainability won out. At that point I
had pushed a few patches with a v1.0 cabal file, so I thought it best
to make this release 2.0.

Who am I?
---------------

I started using HaskellDB in early 2009. I use it more as a
query-generating library than for executing SQL statements. I have
written a largish system for generating a data-access layer in PHP
from query descriptions in HaskellDB. Yes, I'm using Haskell to write
PHP ... dirty!

Unmaintained & Unrelated Packages
-----------------------------------------------------

A couple of haskelldb related packages on Hackage are not maintained by me:

  * haskelldb-hdbc-mysql - This project was created and uploaded
independent of me. Contact the author for specifics. However, the
haskelldb-hdbc-odbc library is maintained by me and can be used to
talk to MySQL.
  * HSQL (haskelldb-hsql, etc)  - I cannot get this backend to compile
on my platform. HSQL seems unmaintained so I have let the drivers
decay. You'll notice I have not uploaded new packages or changed their
version dependencies.
  * haskelldb-flat and haskelldb-dynamic - Both of these packages have
suffered serious bitrot and are not maintained any longer.
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: [Haskelldb-users] ANNOUNCE: HaskellDB 2.0: Scrap your SQL strings

Bas van Dijk-2
Great work!

I think I'm going to use it.

Any plan on packaging up Christopher Done's HaskellDB's type operators:

http://chrisdone.com/posts/2010-10-07-haskelldb-and-typeoperator-madness.html

Which allows you to write something like:

type PersonTable = Table :$: Expr
   :%: Id    ::: Integer
   :+: Age   ::: Integer
   :+: Email ::: String
   :+: Blurb ::: Maybe String
   :+: End

Regards,

Bas
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: [Haskelldb-users] ANNOUNCE: HaskellDB 2.0: Scrap your SQL strings

Justin Bailey
No immediate plans but thanks for pointing that out - I hadn't seen it
yet. Similar functionality exists in the haskelldb-th package, without
the special type operators.

On Fri, Oct 8, 2010 at 5:19 PM, Bas van Dijk <[hidden email]> wrote:

> Great work!
>
> I think I'm going to use it.
>
> Any plan on packaging up Christopher Done's HaskellDB's type operators:
>
> http://chrisdone.com/posts/2010-10-07-haskelldb-and-typeoperator-madness.html
>
> Which allows you to write something like:
>
> type PersonTable = Table :$: Expr
>   :%: Id    ::: Integer
>   :+: Age   ::: Integer
>   :+: Email ::: String
>   :+: Blurb ::: Maybe String
>   :+: End
>
> Regards,
>
> Bas
>
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: [Haskelldb-users] ANNOUNCE: HaskellDB 2.0: Scrap your SQL strings

Christopher Done
On 11 October 2010 16:45, Justin Bailey <[hidden email]> wrote:
> No immediate plans but thanks for pointing that out - I hadn't seen it
> yet. Similar functionality exists in the haskelldb-th package, without
> the special type operators.

Hey that's cool, I hadn't seen that. This'll reduce my code
significantly, especially mkFieldWithName. Cheers!
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: [Haskelldb-users] ANNOUNCE: HaskellDB 2.0: Scrap your SQL strings

Justin Bailey
On Mon, Oct 11, 2010 at 7:56 AM, Christopher Done
<[hidden email]> wrote:
> Hey that's cool, I hadn't seen that. This'll reduce my code
> significantly, especially mkFieldWithName. Cheers!
>

I'm not sure if it supports the "parameterization" of records that you
detailed in your post - let me know how it works for you. Patches
always welcome as well :)

Justin
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: [Haskelldb-users] ANNOUNCE: HaskellDB 2.0: Scrap your SQL strings

John Van Enk
Hooray for collaboration! I think this emphasizes the need for some sort of social aspect on Hackage...

On Mon, Oct 11, 2010 at 10:58 AM, Justin Bailey <[hidden email]> wrote:
On Mon, Oct 11, 2010 at 7:56 AM, Christopher Done
<[hidden email]> wrote:
> Hey that's cool, I hadn't seen that. This'll reduce my code
> significantly, especially mkFieldWithName. Cheers!
>

I'm not sure if it supports the "parameterization" of records that you
detailed in your post - let me know how it works for you. Patches
always welcome as well :)

Justin
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe


_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: ANNOUNCE: HaskellDB 2.0: Scrap your SQL strings

Mats Rauhala
In reply to this post by Justin Bailey
You mentioned that haskelldb was the first library where you weren't
forced to break the abstraction. Do you have a solution to a situation
where you might want to retreive the last inserted id after an insert?

--
Mats Rauhala
MasseR

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe

attachment0 (205 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: ANNOUNCE: HaskellDB 2.0: Scrap your SQL strings

Christopher Done
On 21 February 2012 11:51, Mats Rauhala <[hidden email]> wrote:
> You mentioned that haskelldb was the first library where you weren't
> forced to break the abstraction. Do you have a solution to a situation
> where you might want to retrieve the last inserted id after an insert?

That's a case where I would consider modifying
haskelldb-hdbc-postgresql, for example, to export an insertReturningId
or whatever, because some other engines don't support returning an ID,
and it wouldn't make sense to return Maybe Int or error for the ones
that don't support it. This way it's well-typed.

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe