Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. PostgreSQL
  3. clj-postgresql

clj-postgresql

BSD-2-ClauseClojure

A Clojure library providing PostgreSQL helpers with automatic type conversions and connection management.

GitHubGitHub
162 stars18 forks0 contributors

What is clj-postgresql?

clj-postgresql is a Clojure library that extends clojure.java.jdbc to simplify using advanced PostgreSQL features. It provides seamless type coercion for Clojure data structures like maps and vectors into PostgreSQL types such as JSON, arrays, and timestamps, and leverages PostgreSQL environment variables for connection management. The library reduces boilerplate by automating connections and type conversions, making it easier to integrate PostgreSQL's native capabilities into Clojure applications.

Target Audience

Clojure developers building applications that rely on PostgreSQL's advanced features, such as JSON storage, geometric types, PostGIS spatial data, or array columns. It is particularly useful for teams that want to minimize configuration overhead and leverage PostgreSQL's environment-based connection standards.

Value Proposition

Developers choose clj-postgresql for its automatic integration with PostgreSQL's environment variables and ~/.pgpass, eliminating manual connection setup. Its extensible type conversion system allows seamless use of Clojure-native data structures with PostgreSQL's specialized types, reducing boilerplate and improving developer productivity compared to raw JDBC usage.

Overview

PostgreSQL helpers for Clojure projects

Use Cases

Best For

  • Building Clojure applications that require seamless conversion between Clojure maps/vectors and PostgreSQL JSON/array types.
  • Leveraging PostgreSQL environment variables (PGHOST, PGUSER, etc.) and ~/.pgpass for simplified, secure database connections in Clojure.
  • Working with PostGIS spatial data types like points, linestrings, and polygons in Clojure, with automatic Geometry object handling.
  • Using PostgreSQL geometric types (e.g., points, boxes, circles) directly in Clojure code with helper functions for creation and manipulation.
  • Implementing connection pooling with HikariCP in Clojure PostgreSQL applications for improved performance.
  • Extending type conversions for custom PostgreSQL database types via multimethods for maps, vectors, and numbers.

Not Ideal For

  • Projects using databases other than PostgreSQL, as the library's features are specific to PostgreSQL's type system and environment variables.
  • Teams requiring asynchronous or reactive database access, since clj-postgresql is built on synchronous clojure.java.jdbc with no built-in async support.
  • Applications in dynamic environments where database connections are managed via service discovery or orchestration tools, rather than static environment variables.

Pros & Cons

Pros

Environment-Based Connection Simplification

Automatically uses PGHOST, PGUSER, and other PostgreSQL environment variables along with ~/.pgpass for connections, reducing manual setup as shown in the `pg/spec` and `pg/pool` examples.

Seamless Type Coercion

Extends clojure.java.jdbc to convert Clojure maps, vectors, and sequences directly to PostgreSQL types like JSON, arrays, and timestamps, demonstrated in parameterized queries.

PostGIS and Geometric Utilities

Includes built-in helpers for PostGIS spatial types (e.g., points, polygons) and PostgreSQL geometric types (e.g., boxes, circles), with functions like `st/point` and `pg/circle` for easy manipulation.

Extensible Conversion System

Allows custom type conversions via multimethods for maps, vectors, and numbers, enabling support for user-defined PostgreSQL types as documented in the extensibility section.

Cons

Legacy JDBC Dependency

Built on clojure.java.jdbc, which is older and less performant than modern alternatives like next.jdbc, potentially hindering adoption in new Clojure projects focused on performance.

No Asynchronous Operations

Lacks support for asynchronous database calls, making it unsuitable for high-concurrency applications that require non-blocking I/O, a common need in modern web development.

PostgreSQL-Only Lock-in

Exclusively tailored for PostgreSQL, so projects needing multi-database support or potential migration to other systems cannot use this library without significant rework.

Sparse Advanced Documentation

The README provides basic examples but lacks tutorials on complex use cases, error handling, or best practices, which may increase the learning curve for production deployments.

Frequently Asked Questions

Quick Stats

Stars162
Forks18
Contributors0
Open Issues7
Last commit1 year ago
CreatedSince 2014

Tags

#database-driver#postgis#connection-pooling#postgresql#clojure#hikaricp#type-conversion

Built With

c
clojure.java.jdbc
C
Clojure
P
PostgreSQL
P
PostGIS
H
HikariCP

Included in

PostgreSQL11.8k
Auto-fetched 1 day ago

Related Projects

PostgreSQLPostgreSQL

PostgreSQL client for node.js.

Stars13,145
Forks1,309
Last commit13 days ago
pqpq

Go PostgreSQL driver for database/sql

Stars9,898
Forks955
Last commit19 days ago
rust-postgresqlrust-postgresql

Native PostgreSQL driver for the Rust programming language

Stars3,937
Forks556
Last commit3 days ago
npgsqlnpgsql

Npgsql is the .NET data provider for PostgreSQL.

Stars3,695
Forks879
Last commit3 days ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub