sqlc-hs: Generate type-safe Haskell code from SQL via https://github.com/sqlc-dev/sqlc.

[ apache, development, library, program ] [ Propose Tags ] [ Report a vulnerability ]

library sqlc-hs

library sqlc-hs:sqlc-hs-protos

library sqlc-hs:sqlc-hs-prelude

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.1.0.1
Change log CHANGELOG.md
Dependencies aeson, base (<5.0), bytestring, directory, ede, file-embed, filepath, mtl, proto-lens, proto-lens-runtime, relude, sqlc-hs, text, vector [details]
License Apache-2.0
Author Alex Hansen
Maintainer alex.biehl@gmail.com
Category Development
Home page https://github.com/alexbiehl/sqlc-hs
Bug tracker https://github.com/alexbiehl/sqlc-hs/issues
Source repo head: git clone git@github.com:alexbiehl/sqlc-hs.git
Uploaded by alexbiehl at 2025-04-30T07:38:32Z
Distributions
Executables sqlc-hs
Downloads 2 total (2 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2025-04-30 [all 2 reports]

Readme for sqlc-hs-0.1.0.1

[back to package description]

sqlc-hs

A Haskell code generator plugin for sqlc, allowing you to generate idiomatic Haskell types and functions directly from your SQL queries.

It leverages postgresql-simple, mysql-simple, and sqlite-simple, generating a thin layer on top of these well-known libraries.

Use below configuation in your sqlc.yaml to use sqlc-hs. Refer to the sqlc documentation for more information

version: '2'
plugins:
  - name: haskell
    process:
      cmd: sqlc-hs

Use the plugin for your schemas like so

  codegen:
  - out: gen
    plugin: haskell
    options:
      cabal_package_name: your-package
      cabal_package_version: 0.1.0.0
      haskell_module_prefix: Database.Queries
      overrides:
        db_type: bytea
        haskell_type:
          package: bytestring
          module: Data.ByteString
          type: Data.ByteString.ByteString

Ensure that the sqlc-hs executable is on your PATH when invoking sqlc.

(Re-)Generate proto files with proto-lens

$ protoc --plugin=protoc-gen-haskell=`cabal exec which proto-lens-protoc` --haskell_out=sqlc-hs-protos/ protos/codegen.proto