A thin, F#-friendly wrapper around Npgsql for PostgreSQL database operations with optional static query analysis.
Npgsql.FSharp is a lightweight F# library that wraps the Npgsql PostgreSQL driver for .NET. It provides an idiomatic, pipeline-based API for database operations like querying, parameterization, and transactions, making PostgreSQL access more natural in F# codebases. It solves the problem of cumbersome, low-level database interactions by offering a functional interface that integrates with optional static analysis tools.
F# developers building applications that need to interact with PostgreSQL databases, especially those who prefer functional programming patterns and type-safe database access.
Developers choose Npgsql.FSharp for its clean F#-first API, seamless integration with the Npgsql.FSharp.Analyzer for compile-time query validation, and its balance of simplicity and control without forcing reflection-based mapping.
Thin F# wrapper around Npgsql, the PostgreSQL database driver for .NET
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Uses a pipeline-oriented design (`|>`) that fits naturally with F# code, as shown in examples like `Sql.connect |> Sql.query |> Sql.execute` for fluent query building.
Integrates with Npgsql.FSharp.Analyzer to check SQL syntax and type safety at compile time, reducing runtime errors and enhancing reliability.
Supports various result formats including lists, sequences, and iterative processing with `Sql.iter` for large datasets over 100K rows, optimizing performance.
Provides `OrNone` methods (e.g., `textOrNone`) for dealing with database null values in a type-safe way, avoiding null reference exceptions.
Requires explicit row-to-object mapping functions for each query, which can be verbose and tedious compared to reflection-based ORMs, as acknowledged in the migration section.
To achieve compile-time validation, you must install and configure Npgsql.FSharp.Analyzer separately, adding complexity to the toolchain and build process.
As a thin wrapper over Npgsql, it lacks advanced ORM capabilities like automatic migrations, relationship management, or built-in caching, forcing reliance on external tools or custom code.