PSQL Common Assembly Classes
The PSQL ADO.NET Data Provider supports additional classes that provide enhanced functionality, such as bulk load. All classes are created with 100% managed code. The following classes are provided in the Pervasive.Data.Common.dll assembly:
•
CsvDataReader
•
CsvDataWriter
•
DbBulkCopy
•
DbBulkCopyColumnMapping
•
DbBulkCopyColumnMapping
The classes used for bulk loading implement the generic programming model. They can be used with any DataDirect Technologies ADO.NET data provider or ODBC driver that supports PSQL Bulk Load and any supported database.
CsvDataReader
The CsvDataReader class provides the DataReader semantics for the CSV file format defined by PSQL Bulk Load.
Table
45
lists the public properties for the CsvDataWriter object.
Table 45
Public Properties of the CsvDataReader Object
Property
Description
BulkConfigFile
Specifies the CSV bulk configuration file that is produced when the WriteToFile method is called. A bulk load configuration file defines the names and data types of the columns in the bulk load data file in the same way as the table or result set from which the data was exported. A bulk load configuration file is supported by an underlying XML schema. See
Bulk Load Configuration Files
for an example of the CSV bulk configuration file.
The path may be fully qualified. Otherwise, the file is considered to exist in the current working directory.
NOTE: This property can only be set prior to the Open() call and after the Close() call; otherwise, an InvalidOperationException is thrown.
BulkFile
Specifies the bulk load data file that contains the CSV-formatted bulk data. The file name is used for writing (exporting) and reading (importing) the bulk data. If the file name provided does not contain an extension, the ".csv" extension is assumed.
The path may be fully qualified. Otherwise, the file is considered by default to exist in the current working directory. An InvalidOperationException is thrown if this value is not set.
NOTE: This property can only be set prior to the Open() call and after the Close() call; otherwise, an InvalidOperationException is thrown.
ReadBufferSize
Specifies the size of the read buffer when using bulk load to import data from a data source.
The initial default is 2048 KB.
Values equal to or less than zero cause a System.ArgumentOutOfRangeException to be thrown.
RowOffset
Specifies the row from which to start the bulk load read. The RowOffset is relative to the first (1) row.
The initial default is 1.
Values equal to or less than zero cause a System.ArgumentOutOfRangeException to be thrown.
NOTE: This property can only be set prior to the Open() call and after the Close() call; otherwise, an InvalidOperationException is thrown.
SequentialAccess
Determines whether columns are accessed in order for improved performance.
The initial default is False.
NOTE: This property can only be set prior to the Open() call and after the Close() call; otherwise, an InvalidOperationException is thrown.
Table
46
lists the public methods for the CsvDataReader object.
Table 46
Public Methods of the CsvDataReader Object
Property
Description
Open
Opens the bulk file instance and associated metadatafile for processing.
CsvDataWriter
The CsvDataWriter class provides the DataWriter semantics of the CSV file format that is written by PSQL Bulk Load.
For more information, refer to the data provider’s online help.
Table
47
lists the public properties for the CsvDataWriter object.
Table 47
Public Properties of the CsvDataWriter Object
Property
Description
BinaryThreshold
Specifies the threshold (in KB) at which separate files are generated to store binary data during a bulk unload.
The Initial default is 32.
Values less than zero throw a System.ArgumentOutOfRangeException to be thrown.
CharacterThreshold
Specifies the threshold (in KB) at which separate files are generated to store character data during a bulk unload.
The initial default is 64.
Values less than zero cause a System.ArgumentOutOfRangeException to be thrown.
CsvCharacterSetName
Specifies any of the supported IANA code page names that may be used as values. See
IANA Code Page Mappings
for the supported values.
Applications can obtain the database character that was set using the PsqlConnection.DatabaseCharacterSetName property.
If an unrecognized CharacterSetName is used, an exception is thrown, declaring that invalid character set has been used.
The initial default value is UTF-16.
Note this property enforces the character set used in the CSV data file and overflow files added.
Table
48
lists the public methods for the CsvDataWriter object.
Table 48
Public Methods of the CsvDataWriter Object
Property
Description
Open
Opens the bulk file instance and associated metadatafile for processing.
WriteToFile
Writes the contents of the IDataReader to the bulk data file.
DbBulkCopy
The DbBulkCopy class facilitates copying rows from one data source to another.
The DbBulkCopy object follows the de facto standard defined by the Microsoft SqlBulkCopy class, and has no provider-specific properties or methods. For information about the properties and methods supported, refer to the data provider’s online help and the Microsoft .NET Framework SDK documentation.
DbBulkCopyColumnMapping
The DbBulkCopyColumnMapping class represents a column mapping from the data sources table to a destination table.
The DbBulkCopyColumnMapping object follows the de facto standard defined by the Microsoft SqlBulkCopyColumnMapping class, and has no provider-specific properties or methods. For information about the properties and methods supported, refer to the data provider’s online help and the Microsoft .NET Framework SDK documentation.
DbBulkCopyColumnMappingCollection
The DbBulkCopyColumnMappingCollection class is a collection of DbBulkCopyColumnMapping objects.
The DbBulkCopyColumnMappingCollection object follows the de facto standard defined by the Microsoft SqlBulkCopyColumnMappingCollection class, and has no provider-specific properties or methods. For information about the properties and methods supported, refer to the data provider’s online help and the Microsoft .NET Framework SDK documentation.