yeshql-core

YesQL-style SQL database abstraction (core)

https://github.com/tdammers/yeshql

Version on this page:4.1.0.2
LTS Haskell 22.41:4.2.0.0
Stackage Nightly 2024-11-12:4.2.0.0
Latest on Hackage:4.2.0.0

See all snapshots yeshql-core appears in

MIT licensed by Tobias Dammers
Maintained by [email protected]
This version can be pinned in stack with:yeshql-core-4.1.0.2@sha256:59cc047529c19cfb10eb951228522c74be5dc1bdea4b3953c4388710926f3789,1576

Module documentation for 4.1.0.2

YeshQL

YesQL-style SQL database abstraction.

YeshQL implements quasiquoters that allow the programmer to write SQL queries in SQL, and embed these into Haskell programs using quasi-quotation. YeshQL takes care of generating suitable functions that will run the SQL queries against a HDBC database driver, and marshal values between Haskell and SQL.

In order to do this properly, YeshQL extends SQL syntax with type annotations and function names; other than that, it is perfectly ignorant about the SQL syntax itself. See the YesQL Readme for the full rationale - Haskell and Clojure are sufficiently different languages, but the reasoning behind YesQL applies to YeshQL almost unchanged.

Installation

Use stack or cabal to install. Nothing extraordinary here.

Usage

In short:

{-#LANGUAGE QuasiQuotes #-}
import MyProject.DatabaseConnection (withDB)
import Database.HDBC
import Database.YeshQL

[yesh|
  -- name:getUser :: (String)
  -- :userID :: Int
  SELECT username FROM users WHERE id = :userID
|] 

main = withDB $ \conn -> do
  username <- getUser 1 conn
  putStrLn username

Please refer to the Haddock documentation for further usage details.

Bugs

Probably. The project is hosted at https://github.com/tdammers/yeshql, feel free to comment there or send a message to [email protected] if you find any.

Something about the name

YeshQL is rather heavily inspired by YesQL, so it makes sense to blatantly steal most of the name. Throwing in an “H” for good measure (this being Haskell and all) makes it sound like Sean Connery, which automatically increases aweshomenesh, so that’sh what we’ll roll with.

License / Copying

YeshQL is Free Software and provided as-is. Please see the enclosed LICENSE file for details.