https://github.com/prosumma/postgresqlexporter
A simple library to create PostgreSQL-friendly import files
https://github.com/prosumma/postgresqlexporter
Last synced: 8 months ago
JSON representation
A simple library to create PostgreSQL-friendly import files
- Host: GitHub
- URL: https://github.com/prosumma/postgresqlexporter
- Owner: Prosumma
- License: mit
- Created: 2017-01-31T03:37:10.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-06-29T23:57:16.000Z (almost 9 years ago)
- Last Synced: 2025-05-23T04:28:57.985Z (about 1 year ago)
- Language: C#
- Size: 9.77 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
### PostgreSQL Exporter
A simple library for exporting data that is compatible with PostgreSQL's `\COPY` command.
Here's a quick example:
```cs
using (var connection = new SqlConnection(ConnectionString))
{
connection.Open();
var command = connection.CreateCommand();
command.CommandText = "SELECT * FROM [Cornholios]";
using (var reader = command.ExecuteReader())
{
var exporter = new Exporter { ProgressInterval = 100000 };
exporter.Progress += (sender, e) =>
{
Console.WriteLine($"Wrote {e.Count} records.");
};
exporter.Export(reader, Environment.ExpandEnvironmentVariables("%USERPROFILE%\\Desktop\\Cornholios.tsv"));
}
}
```