Prosumma / PostgreSQLExporter

A simple library to create PostgreSQL-friendly import files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PostgreSQL Exporter

A simple library for exporting data that is compatible with PostgreSQL's \COPY command.

Here's a quick example:

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"));
    }
}

About

A simple library to create PostgreSQL-friendly import files

License:MIT License


Languages

Language:C# 100.0%