Npgsql
10.0.2
39 download(s)
public
Npgsql is the open source .NET data provider for PostgreSQL.
npgsql
postgresql
postgres
ado
ado.net
database
sql
PackageReference
<PackageReference Include="Npgsql" Version="10.0.2" />
.NET CLI
dotnet add package Npgsql --version 10.0.2
Dependencies
net10.0
| Package | Version range |
|---|---|
| Microsoft.Extensions.Logging.Abstractions | [10.0.0, ) |
net8.0
| Package | Version range |
|---|---|
| Microsoft.Extensions.Logging.Abstractions | [8.0.0, ) |
| System.Diagnostics.DiagnosticSource | [9.0.11, ) |
net9.0
| Package | Version range |
|---|---|
| Microsoft.Extensions.Logging.Abstractions | [9.0.0, ) |
Readme
Npgsql is the open source .NET data provider for PostgreSQL. It allows you to connect and interact with PostgreSQL server using .NET.
## Quickstart
Here's a basic code snippet to get you started:
```csharp
var connString = "Host=myserver;Username=mylogin;Password=mypass;Database=mydatabase";
await using var conn = new NpgsqlConnection(connString);
await conn.OpenAsync();
// Insert some data
await using (var cmd = new NpgsqlCommand("INSERT INTO data (some_field) VALUES (@p)", conn))
{
cmd.Parameters.AddWithValue("p", "Hello world");
await cmd.ExecuteNonQueryAsync();
}
// Retrieve all rows
await using (var cmd = new NpgsqlCommand("SELECT some_field FROM data", conn))
await using (var reader = await cmd.ExecuteReaderAsync())
{
while (await reader.ReadAsync())
Console.WriteLine(reader.GetString(0));
}
```
## Key features
* High-performance PostgreSQL driver. Regularly figures in the top contenders on the [TechEmpower Web Framework Benchmarks](https://www.techempower.com/benchmarks/).
* Full support of most PostgreSQL types, including advanced ones such as arrays, enums, ranges, multiranges, composites, JSON, PostGIS and others.
* Highly-efficient bulk import/export API.
* Failover, load balancing and general multi-host support.
* Great integration with Entity Framework Core via [Npgsql.EntityFrameworkCore.PostgreSQL](https://www.nuget.org/packages/Npgsql.EntityFrameworkCore.PostgreSQL).
For the full documentation, please visit [the Npgsql website](https://www.npgsql.org).
## Related packages
* The Entity Framework Core provider that works with this provider is [Npgsql.EntityFrameworkCore.PostgreSQL](https://www.nuget.org/packages/Npgsql.EntityFrameworkCore.PostgreSQL).
* Spatial plugin to work with PostgreSQL PostGIS: [Npgsql.NetTopologySuite](https://www.nuget.org/packages/Npgsql.NetTopologySuite)
* NodaTime plugin to use better date/time types with PostgreSQL: [Npgsql.NodaTime](https://www.nuget.org/packages/Npgsql.NodaTime)
* OpenTelemetry support can be set up with [Npgsql.OpenTelemetry](https://www.nuget.org/packages/Npgsql.OpenTelemetry)
Versions
Target frameworks
net10.0
net8.0
net9.0
Metadata
- Published
- Size
- 1.76 MB
- Authors
- Shay Rojansky,Nikita Kazmin,Brar Piening,Nino Floris,Yoh Deadfall,Austin Drenski,Emil Lenngren,Francisco Figueiredo Jr.,Kenji Uno
- License
- PostgreSQL
- Project
- https://github.com/npgsql/npgsql
- Repository
- https://github.com/npgsql/npgsql commit 4d57e27b370e2ab2a350ad8bcef78d7ddd97e5ea
- Flags
- SemVer 1
- SHA512
- 6TSGeah775ahq/3SP3nYFSPGpl5r3cPxQxbP7hxHcAJC8XvSEZlg2gZPIhaSEp1sN4VbHllDFZWADm/Y/YJAoQ==