C# Class Azavea.NijPredictivePolicing.Parsers.AccessDBValueWriter

a basic implementation of the IDataWriter interface, so we can simply export tab separated value files
Inheritance: IDataFileWriter
Show file Open project: azavea/acs-alchemist

Protected Properties

Property Type Description
_conn System.Data.Common.DbConnection
_filename string
_insertCmd System.Data.Common.DbCommand
_tablename string
_tablenames List

Public Methods

Method Description
AccessDBValueWriter ( ) : System

construct a new blank writer (any writes will throw exceptions if you don't set a stream or a file!)

AccessDBValueWriter ( string filename ) : System

construct a new writer to append to the given file

Close ( ) : bool

closes the underlying stream

CreateTable ( string tablename, IEnumerable columns ) : bool
Flush ( ) : bool

flushes the stream

IsOpen ( ) : bool

returns true if the database connection is open and ready

SetTablename ( string tableName ) : void
SetWriteFile ( string filename ) : bool

Opens or creates an MS Access database file for writing

TableNames ( ) : List

pulls a list of datatable names from the database and caches them. (this list does not refresh, because this reader is read-only)

WriteLine ( IEnumerable values ) : bool

Make sure you have a value for every column! This is really intentionally not thread safe, do not share this class across threads.

Method Details

AccessDBValueWriter() public method

construct a new blank writer (any writes will throw exceptions if you don't set a stream or a file!)
public AccessDBValueWriter ( ) : System
return System

AccessDBValueWriter() public method

construct a new writer to append to the given file
public AccessDBValueWriter ( string filename ) : System
filename string
return System

Close() public method

closes the underlying stream
public Close ( ) : bool
return bool

CreateTable() public method

public CreateTable ( string tablename, IEnumerable columns ) : bool
tablename string
columns IEnumerable
return bool

Flush() public method

flushes the stream
public Flush ( ) : bool
return bool

IsOpen() public method

returns true if the database connection is open and ready
public IsOpen ( ) : bool
return bool

SetTablename() public method

public SetTablename ( string tableName ) : void
tableName string
return void

SetWriteFile() public method

Opens or creates an MS Access database file for writing
public SetWriteFile ( string filename ) : bool
filename string
return bool

TableNames() public method

pulls a list of datatable names from the database and caches them. (this list does not refresh, because this reader is read-only)
public TableNames ( ) : List
return List

WriteLine() public method

Make sure you have a value for every column! This is really intentionally not thread safe, do not share this class across threads.
public WriteLine ( IEnumerable values ) : bool
values IEnumerable
return bool

Property Details

_conn protected property

an open connection to the database (opened when constructed, or from LoadFile)
protected DbConnection,System.Data.Common _conn
return System.Data.Common.DbConnection

_filename protected property

the ms access database filename
protected string _filename
return string

_insertCmd protected property

a reusable parameterized insert command to help speed up our writer.
protected DbCommand,System.Data.Common _insertCmd
return System.Data.Common.DbCommand

_tablename protected property

the currently selected table name in the ms access database
protected string _tablename
return string

_tablenames protected property

a one-time cached of tables available in the database
protected List _tablenames
return List