Orc.DbToCsv

Name Badge
Chat Join the chat at https://gitter.im/WildGums/Orc.DbToCsv
Downloads NuGet downloads
Stable version Version
Unstable version Pre-release version

Find the source at https://github.com/WildGums/Orc.DbToCsv

This library’s sole purpose is to extract data from a MS SQL database into csv files. Each table or view will have a corresponding csv file.

The repository contains a library, a command line utility and a task runner

Usage

In order to extract the data the library needs a project file. A project file is simply an xml file with an “.iprj” extension, and looks like:

<Project xmlns="http://wildgums/2015">
  <ConnectionString>Data Source=.\SQLExpress;Initial Catalog=MyDbName;Integrated Security=True;Pooling=False</ConnectionString>
  <MaximumRowsInTable>500</MaximumRowsInTable>
  <OutputFolder>C:\Temp\CustomPath</OutputFolder>
  
  <Project.Tables>
    <Table Name="MyTable1"/>
    <Table Name="MyTable2" Csv="Table2.csv"/>
    <Table Name="MyTable3" Csv="Table3.csv" Output="C:\Temp"/>
  </Project.Tables>
</Project>

There are four important tags:

Note: - You can specify the csv file name for each table/view using the Csv attribute. - If the Csv attribute is left blank or does not exist the default file name will be the table name (except white spaces will be replaced with an underscore.) - You can specify a different output directory for each file. If left blank or does not exist the file will be saved in the “OutputFolder”.

Once the project file is setup you can create the csv files using the following command:

public static void ProcessProject(string projectFilePath, string outputFolderPath, ILogWriter logWriter)

Example:

Importer.ProcessProject(projectFilePath, outputFolderPath, new ConsoleWriter());

The parameters are:

Command line utility (Orc.DbToCsv.Console)

Orc.DbToCsv.Console is a simple command line utility.

There are two possible command line options:

Example:

Orc.DbToCsv.Console.exe -p E:\sample1.iprj -o D:\output

Task Runner

TaskRunner


Have a question about Catel or WildGums controls? Use StackOverflow with the Catel tag!


Discussion