I’ve published a new package named sqlite-easy. It’s not much of an original content as much as it’s a basic wrapper around some functionality of direct-sqlite, migrant-core, and resource-pool.
The basic idea is making it low-effort to embed a simple database or persist some state for simple applications with just a bit of writing and not a lot of reading.
It includes support for connecting to a sqlite database, running queries, migrations, and simple transactions.
The package is experimental and is not recommended for use in serious projects or production setting, but if you have a toy project that could benefit from it, consider trying it!
You can quickly try it out in ghci if you’d like:
➜ cabal repl --build-depends sqlite-easy
[...]
λ> :set -XOverloadedStrings
λ> import Database.Sqlite.Easy
λ> withDb ":memory:" $ run "select 1 + 1"
[[SQLInteger 2]]
λ>
λ> pool <- createSqlitePool "/tmp/mysqliteasydb.bin"
λ> withPool pool $ run "create table t (x text)"
[]
λ> :{
λ| withPool pool $
λ| transaction $ do
λ| run "insert into t values ('a'),('b'),('c')"
λ| run "insert into t values ('b'),('a'),('b')"
λ| :}
[]
λ> withPool pool $ runWith "select x, count(x) from t where x <> ? group by x" [SQLText "c"]
[[SQLText "a",SQLInteger 2],[SQLText "b",SQLInteger 3]]
- You can find the docs here: Database.Sqlite.Easy
- And an example project here: GitHub - soupi/sqlite-easy-example-todo: A primitive todo list app as an example of sqlite-easy.