postgresql-simple-named alternatives and similar packages
Based on the "postgresql" category.
Alternatively, view postgresql-simple-named alternatives based on common mentions on social networks and blogs.
-
postgresql-simple
Mid-level client library for accessing PostgreSQL from Haskell -
postgresql-simple-migration
PostgreSQL Schema Migrations for Haskell -
postgresql-tx
[Moved to: https://github.com/Simspace/postgresql-tx] -
postgresql-typed
Haskell PostgreSQL library with compile-time type inference -
postgresql-orm
An Haskell ORM (Object Relational Mapping) and migrations DSL for PostgreSQL. -
postgresql-transactional
Transactional monadic actions on top of PostgreSQL. -
postgresql-libpq
Low-level Haskell bindings for libpq -
postgresql-pure
a PostgreSQL client library implemented with pure Haskell -
postgresql-syntax
PostgreSQL SQL syntax utilities -
postgresql-schema
PostgreSQL Schema is a database migration tool. -
postgresql-simple-interpolate
Safe interpolated SQL queries in Haskell -
postgresql-simple-typed
TypedQuery flavour for postgresql-simple -
postgresql-simple-opts
An optparse-applicative parser for postgresql-simple's connection options -
postgresql-error-codes
PostgreSQL error codes -
postgresql-libpq-notify
A postgresql notifications library for libpq -
postgresql-placeholder-converter
Converter for question mark style and dollar sign style of PostgreSQL SQL. -
postgresql-lo-stream
Utilities for streaming PostgreSQL LargeObjects -
postgresql-tx-monad-logger
postgresql-tx interfacing for use with monad-logger. -
postgresql-tx-query
postgresql-tx interfacing for use with postgresql-query. -
postgresql-tx-simple
postgresql-tx interfacing for use with postgresql-simple. -
postgresql-tx-squeal
postgresql-tx interfacing for use with squeal-postgresql.
Access the most powerful time series database as a service
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of postgresql-simple-named or a related project?
README
postgresql-simple-named
This library introduces the implementation of named parameters for the
postgresql-simple
library. postgresql-simple-named
is considered to
be used along with the postgresql-simple
library, so you could refer
there for the original documentation of primary functions. This package solves
exclusively one particular problem — gives the ability to use named parameters
instead of ?
in quasi-quoter queries and offers essential functions for substituting
variables in queries (queryNamed
, executeNamed
).
Example
Operator =?
binds named parameters with the corresponding values. Named
parameters inside SQL query start with the '?' character and can contain
lowercase and uppercase letters, digits and underscore. Below you can find a
basic example of how query with named parameters could look like:
queryNamed dbConnection [sql|
SELECT
id, name, city
FROM users
WHERE name = ?nameParam
AND age = ?ageParam
|] [ "nameParam" =? "John"
, "ageParam" =? 42
]
This feature can be extremely helpful when the query uses some parameters more than once:
query dbConnection [sql|
SELECT
col1, col2
FROM my_table
WHERE id = ?
AND (? IS NULL OR id > ? )
AND (? IS NULL OR id < ? )
|] (someId, minId, minId, maxId, maxId)
This is how the query looks like with the postgresql-simple
library. You can
rewrite it the following way using the postgresql-simple-named
library:
queryNamed dbConnection [sql|
SELECT
col1, col2
FROM my_table
WHERE id = ?someId
AND (?minId IS NULL OR id > ?minId )
AND (?maxId IS NULL OR id < ?maxId )
|] [ "someId" =? 42
, "minId" =? 1
, "maxId" =? 100
]
How to build
Build the library with either cabal new-build
or stack build
.
How to test locally
- Run DB in a Docker in a separate terminal window using command:
docker run -p 5432\:5432 -e POSTGRES_USER=postgres -e POSTGRES_DB=pg_named postgres\:10.5-alpine
- Run tests using
cabal new-test
orstack test
*Note that all licence references and agreements mentioned in the postgresql-simple-named README section above
are relevant to that project's source code only.