SQL Relay C++ API
Public Member Functions | Protected Member Functions | List of all members
sqlrimport Class Reference

#include <sqlrimport.h>

Inherited by sqlrimportfile [virtual].

Public Member Functions

 sqlrimport ()
 
virtual ~sqlrimport ()
 
void setSqlrConnection (sqlrconnection *sqlrcon)
 
void setSqlrCursor (sqlrcursor *sqlrcur)
 
sqlrconnectiongetSqlrConnection ()
 
sqlrcursorgetSqlrCursor ()
 
void insertPrimaryKey (const char *primarykeycolumnname, uint32_t primarykeycolumnindex, const char *primarykeysequence)
 
void removePrimaryKey ()
 
bool getInsertPrimaryKey ()
 
const char * getPrimaryKeyColumnName ()
 
uint32_t getPrimaryKeyColumnIndex ()
 
const char * getPrimaryKeySequence ()
 
void insertStaticValue (const char *columnname, uint32_t columnindex, const char *value)
 
void removeStaticValue (uint32_t columnindex)
 
const char * getStaticValueColumnName (uint32_t index)
 
const char * getStaticValue (uint32_t index)
 
uint32_t getStaticValueCount ()
 
void setDbType (const char *dbtype)
 
const char * getDbType ()
 
void setObjectName (const char *objectname)
 
const char * getObjectName ()
 
void setIgnoreColumns (bool ignorecolumns)
 
bool getIgnoreColumns ()
 
void setIgnoreColumnsWithEmptyNames (bool ignorecolumnswithemptynames)
 
bool getIgnoreColumnsWithEmptyNames ()
 
void setIgnoreEmptyRows (bool ignoreemptyrows)
 
bool getIgnoreEmptyRows ()
 
void mapColumnName (const char *from, const char *to)
 
const char * getMappedColumnName (const char *from)
 
void setMixedCaseColumnNames ()
 
bool getMixedCaseColumnNames ()
 
void setLowerCaseColumnNames ()
 
bool getLowerCaseColumnNames ()
 
void setUpperCaseColumnNames ()
 
bool getUpperCaseColumnNames ()
 
void mapFieldValue (const char *from, const char *to)
 
const char * getMappedFieldValue (const char *from)
 
void setReformatDateTime (bool reformatdatetime)
 
bool getReformatDateTime ()
 
void setDdMm (bool ddmm)
 
bool getDdMm ()
 
void setYyyyDdMm (bool yyyyddmm)
 
bool getYyyyDdMm ()
 
void setDateDelimiters (const char *datedelimiters)
 
const char * getDateDelimiters ()
 
void setNoCenturyThreshold (uint16_t nocenturythreshold)
 
uint16_t getNoCenturyThreshold ()
 
void setLastCenturyThreshold (uint16_t lastcenturythreshold)
 
uint16_t getLastCenturyThreshold ()
 
void setDateTimeFormat (const char *datetimeformat)
 
const char * getDateTimeFormat ()
 
void setCommitCount (uint64_t commitcount)
 
uint64_t getCommitCount ()
 
void setLogger (logger *lg)
 
logger * getLogger ()
 
void setCoarseLogLevel (uint8_t coarseloglevel)
 
uint8_t getCoarseLogLevel ()
 
void setFineLogLevel (uint8_t fineloglevel)
 
uint8_t getFineLogLevel ()
 
void setLogIndent (uint32_t logindent)
 
uint32_t getLogIndent ()
 
void setLogErrors (bool logerrors)
 
bool getLogErrors ()
 
virtual bool importData ()
 
uint64_t getImportedRowCount ()
 

Protected Member Functions

virtual bool importStart ()
 
virtual bool columnsStart ()
 
virtual bool columnStart ()
 
virtual bool columnEnd ()
 
virtual bool columnsEnd ()
 
virtual bool rowsStart ()
 
virtual bool rowStart ()
 
virtual bool fieldStart ()
 
virtual bool fieldEnd ()
 
virtual bool rowEnd ()
 
virtual bool rowsEnd ()
 
virtual bool beginStart ()
 
virtual bool beginEnd ()
 
virtual bool commitStart ()
 
virtual bool commitEnd ()
 
virtual bool error (int64_t errornumber, const char *errormessage)
 
virtual bool importEnd ()
 
void setExcludeRow (bool excluderow)
 
bool getExcludeRow ()
 
void setCurrentRow (uint64_t currentrow)
 
uint64_t getCurrentRow ()
 
void setCurrentColumn (uint32_t currentcol)
 
uint32_t getCurrentColumn ()
 
void setCurrentColumnName (char *currentcolname)
 
char * getCurrentColumnName ()
 
void setCurrentField (char *currentfield)
 
char * getCurrentField ()
 
void setIsNumericColumn (uint64_t index, bool numeric)
 
bool getIsNumericColumn (uint64_t index)
 
void clearAreNumericColumns ()
 
void setIsDateTimeColumn (uint64_t index, bool datetime)
 
bool getIsDateTimeColumn (uint64_t index)
 
void clearAreDateTimeColumns ()
 
void setImportedRowCount (uint64_t importedrowcount)
 

Detailed Description

The sqlrimport class provides a base class for child classes that wish to implement import of data from a file into a database, via SQL Relay. It provides various common methods. Each child class must implement the importData() method.

Constructor & Destructor Documentation

◆ sqlrimport()

sqlrimport::sqlrimport ( )

Creates an instance of the sqlrimport class.

◆ ~sqlrimport()

virtual sqlrimport::~sqlrimport ( )
virtual

Destroys this instance of the sqlrimport class.

Member Function Documentation

◆ beginEnd()

virtual bool sqlrimport::beginEnd ( )
protectedvirtual

This method should be called after a begin().

This implementation just returns true but a child class may override this method to do something else.

Should return true on success and false if an error occurred and import should stop if this method return false.

◆ beginStart()

virtual bool sqlrimport::beginStart ( )
protectedvirtual

This method should be called before a begin().

This implementation just returns true but a child class may override this method to do something else.

Should return true on success and false if an error occurred and import should stop if this method return false.

◆ clearAreDateTimeColumns()

void sqlrimport::clearAreDateTimeColumns ( )
protected

Clears the data types of all columns, setting them to to non-date/time.

Not commonly called by implementations of the *Start/End() methods.

◆ clearAreNumericColumns()

void sqlrimport::clearAreNumericColumns ( )
protected

Clears the data types of all columns, setting them to to non-numeric.

Not commonly called by implementations of the *Start/End() methods.

◆ columnEnd()

virtual bool sqlrimport::columnEnd ( )
protectedvirtual

This method should be called after the import of each column.

This implementation just returns true but a child class may override this method to do something else.

At this point, unless specifically set otherwise in an overridden method...

Note that this method is called whether or not a column is ignored. For example... If setIgnoreColums(true) has been called, then this method will still be called for each column. If setIgnoreColumnsWithEmptyNames(true) has been called, then this method will still be called for each column, whether it is empty or not. getCurrentColumnName() will also return the (possibly empty) column name.

Should return true on success and false if an error occurred and import should stop if this method return false.

◆ columnsEnd()

virtual bool sqlrimport::columnsEnd ( )
protectedvirtual

This method should be called after the import of the columns.

This implementation just returns true but a child class may override this method to do something else.

At this point, unless specifically set otherwise in an overridden method...

Should return true on success and false if an error occurred and import should stop if this method return false.

◆ columnsStart()

virtual bool sqlrimport::columnsStart ( )
protectedvirtual

This method should be called prior to the import of the columns.

This implementation just returns true but a child class may override this method to do something else.

At this point, unless specifically set otherwise in an overridden method...

Should return true on success and false if an error occurred and import should stop if this method return false.

◆ columnStart()

virtual bool sqlrimport::columnStart ( )
protectedvirtual

This method should be called prior to the import of each column.

This implementation just returns true but a child class may override this method to do something else.

At this point, unless specifically set otherwise in an overridden method...

If you want to modify the value of the column name that is going to be imported, this is a good method to override and call setCurrentColumnName(). Note that setCurrentColumnName() takes a char *, not a const char * argument. A buffer must be allocated, populated, and passed in to it, and that buffer will eventually be deallocated by this class. Plan accordingly.

Note that this method is called whether or not a column is ignored. For example... If setIgnoreColums(true) has been called, then this method will still be called for each column. If setIgnoreColumnsWithEmptyNames(true) has been called, then this method will still be called for each column, whether it is empty or not. getCurrentColumnName() will also return the (possibly empty) column name.

Should return true on success and false if an error occurred and import should stop if this method return false.

◆ commitEnd()

virtual bool sqlrimport::commitEnd ( )
protectedvirtual

This method should be called after a commit().

This implementation just returns true but a child class may override this method to do something else.

Should return true on success and false if an error occurred and import should stop if this method return false.

◆ commitStart()

virtual bool sqlrimport::commitStart ( )
protectedvirtual

This method should be called before a commit().

This implementation just returns true but a child class may override this method to do something else.

Should return true on success and false if an error occurred and import should stop if this method return false.

◆ error()

virtual bool sqlrimport::error ( int64_t errornumber,
const char * errormessage )
protectedvirtual

This method should be called if a commit(), begin(), executeQuery(), or other database operation fails.

This implementation just returns false but a child class may override this method to do something else.

Should return true if import may continue, or false if should stop.

◆ fieldEnd()

virtual bool sqlrimport::fieldEnd ( )
protectedvirtual

This method should be called after the import of each field.

This implementation just returns true but a child class may override this method to do something else.

At this point, unless specifically set otherwise in an overridden method...

Note that this method is called whether or not a column or row is ignored or excluded. For example... If setIgnoreColumnsWithEmptyNames(true) has been called, then this method will still be called for each column, whether it is empty or not. getCurrentColumnName() will also return the (possibly empty) column name. If setIgnoreEmptyRows(true) has been called then this method will still be called for each column of each empty row. getCurrentField() will also return the (possibly empty) field.

Should return true on success and false if an error occurred and import should stop if this method return false.

◆ fieldStart()

virtual bool sqlrimport::fieldStart ( )
protectedvirtual

This method should be called prior to the import of each field.

This implementation just returns true but a child class may override this method to do something else.

At this point, unless specifically set otherwise in an overridden method...

If you want to modify the value of the field that is going to be imported, this is a good method to override and call setCurrentField(). Note that setCurrentField() takes a char *, not a const char * argument. A buffer must be allocated, populated, and passed in to it, and that buffer will eventually be deallocated by this class. Plan accordingly.

Note that this method is called whether or not a column or row is ignored or excluded. For example... If setIgnoreColumnsWithEmptyNames(true) has been called, then this method will still be called for each column, whether it is empty or not. getCurrentColumnName() will also return the (possibly empty) column name. If setIgnoreEmptyRows(true) has been called then this method will still be called for each column of each empty row. getCurrentField() will also return the (possibly empty) field.

Should return true on success and false if an error occurred and import should stop if this method return false.

◆ getCoarseLogLevel()

uint8_t sqlrimport::getCoarseLogLevel ( )

Returns the coarse log level.

◆ getCommitCount()

uint64_t sqlrimport::getCommitCount ( )

Returns the commit count.

◆ getCurrentColumn()

uint32_t sqlrimport::getCurrentColumn ( )
protected

Gets the index of the column that is currently being imported.

May be called by implementations of the *Start/End() methods.

◆ getCurrentColumnName()

char * sqlrimport::getCurrentColumnName ( )
protected

Gets the name of the column that is currently being imported.

May be called by implementations of the *Start/End() methods.

◆ getCurrentField()

char * sqlrimport::getCurrentField ( )
protected

Gets the value of the field that is currently being imported.

May be called by implementations of the *Start/End() methods.

◆ getCurrentRow()

uint64_t sqlrimport::getCurrentRow ( )
protected

Gets the index of the row that is currently being imported.

May be called by implementations of the *Start/End() methods.

◆ getDateDelimiters()

const char * sqlrimport::getDateDelimiters ( )

Returns the value of the most recent call to setDateDelimiters() or NULL if setDateDelimiters() has never been called.

◆ getDateTimeFormat()

const char * sqlrimport::getDateTimeFormat ( )

Returns the value of the most recent call to setDateTimeFormat() or "YYYY-MM-DD HH24:MI:SS" if setDateTimeFormat() has never been called.

◆ getDbType()

const char * sqlrimport::getDbType ( )

Returns the database type as set by setDbType().

◆ getDdMm()

bool sqlrimport::getDdMm ( )

Returns the value of the most recent call to setDdMm() or false if setDdMm() has never been called.

◆ getExcludeRow()

bool sqlrimport::getExcludeRow ( )
protected

Gets whether the current row of will be excluded or not. Rows that are excluded are not imported.

May be called by implementations of the *Start/End() methods.

◆ getFineLogLevel()

uint8_t sqlrimport::getFineLogLevel ( )

Returns the fine log level.

◆ getIgnoreColumns()

bool sqlrimport::getIgnoreColumns ( )

Returns whether or not column information will be ignored.

◆ getIgnoreColumnsWithEmptyNames()

bool sqlrimport::getIgnoreColumnsWithEmptyNames ( )

Returns whether or not columns with empty names will be ignored.

◆ getIgnoreEmptyRows()

bool sqlrimport::getIgnoreEmptyRows ( )

Returns whether or not empty rows will be ignored.

◆ getImportedRowCount()

uint64_t sqlrimport::getImportedRowCount ( )

Returns the number of rows that were imported by the most recent call to importData(), or the current number of rows that have been imported, if called from inside one of the Start()/End() methods.

◆ getInsertPrimaryKey()

bool sqlrimport::getInsertPrimaryKey ( )

Returns whether or not a primary key will be inserted, as set by insertPrimaryKey().

◆ getIsDateTimeColumn()

bool sqlrimport::getIsDateTimeColumn ( uint64_t index)
protected

Get whether the data type of the column in position "index" is a date/time type or not.

May be called by implementations of the *Start/End() methods.

◆ getIsNumericColumn()

bool sqlrimport::getIsNumericColumn ( uint64_t index)
protected

Get whether the data type of the column in position "index" is a numeric type or not.

May be called by implementations of the *Start/End() methods.

◆ getLastCenturyThreshold()

uint16_t sqlrimport::getLastCenturyThreshold ( )

Returns the value of the most recent call to setLastCenturyThreshold() or 10 if setLastCenturyThreshold() has never been called.

◆ getLogErrors()

bool sqlrimport::getLogErrors ( )

Returns true if SQL errors will be logged at the coarse log level and false otherwise.

◆ getLogger()

logger * sqlrimport::getLogger ( )

Returns the logger that is set to use when logging progress or NULL if no logger is set.

◆ getLogIndent()

uint32_t sqlrimport::getLogIndent ( )

Returns the log indent.

◆ getLowerCaseColumnNames()

bool sqlrimport::getLowerCaseColumnNames ( )

Returns true if column names are lower-cased and false otherwise.

◆ getMappedColumnName()

const char * sqlrimport::getMappedColumnName ( const char * from)

Returns the name that "from" is mapped to, or NULL if "from" is not mapped to anything.

◆ getMappedFieldValue()

const char * sqlrimport::getMappedFieldValue ( const char * from)

Returns the value that "from" is mapped to, or NULL if "from" is not mapped to anything.

◆ getMixedCaseColumnNames()

bool sqlrimport::getMixedCaseColumnNames ( )

Returns true if column names are left as-is and false otherwise.

◆ getNoCenturyThreshold()

uint16_t sqlrimport::getNoCenturyThreshold ( )

Returns the value of the most recent call to setNoCenturyThreshold() or 100 if setNoCenturyThreshold() has never been called.

◆ getObjectName()

const char * sqlrimport::getObjectName ( )

Returns the object name as set by setObjectName().

◆ getPrimaryKeyColumnIndex()

uint32_t sqlrimport::getPrimaryKeyColumnIndex ( )

Returns the primary key column index as set by insertPrimaryKey() or 0 if insertPrimaryKey() was never called, or if removePrimaryKey() was called.

◆ getPrimaryKeyColumnName()

const char * sqlrimport::getPrimaryKeyColumnName ( )

Returns the primary key column name as set by insertPrimaryKey() or NULL if insertPrimaryKey() was never called, or if removePrimaryKey() was called.

◆ getPrimaryKeySequence()

const char * sqlrimport::getPrimaryKeySequence ( )

Returns the primary key column sequence as set by insertPrimaryKey() or NULL if insertPrimaryKey() was never called, or if removePrimaryKey() was called.

◆ getReformatDateTime()

bool sqlrimport::getReformatDateTime ( )

Returns whether or not date/time fields will be reformatted prior to import.

◆ getSqlrConnection()

sqlrconnection * sqlrimport::getSqlrConnection ( )

Returns the instance of sqlrconnection that this instance is configured to use to insert data for the import.

◆ getSqlrCursor()

sqlrcursor * sqlrimport::getSqlrCursor ( )

Returns the instance of sqlrursor that this instance is configured to use to insert data for the import.

◆ getStaticValue()

const char * sqlrimport::getStaticValue ( uint32_t index)

Returns the static value that will be inserted at "index" as set by insertStaticValue() or NULL if insertStaticValue() was never called, or if removeStaticValue() was called.

◆ getStaticValueColumnName()

const char * sqlrimport::getStaticValueColumnName ( uint32_t index)

Returns the column name for the static value that will be inserted at "index" as set by insertStaticValue() or NULL if insertStaticValue() was never called, or if removeStaticValue() was called.

◆ getStaticValueCount()

uint32_t sqlrimport::getStaticValueCount ( )

Returns the number of static values that will be inserted as set by calls to insertStaticValue() or 0 if insertStaticValue() was never called, or if removeStaticValue() was called.

◆ getUpperCaseColumnNames()

bool sqlrimport::getUpperCaseColumnNames ( )

Returns true if column names are upper-cased and false otherwise.

◆ getYyyyDdMm()

bool sqlrimport::getYyyyDdMm ( )

Returns the value of the most recent call to setYyyyDdMm() or false if setYyyyDdMm() has never been called.

◆ importData()

virtual bool sqlrimport::importData ( )
virtual

Imports data.

If setCommitCount() was called with a non-zero value then a commit will be called after every "commitcount" rows is inserted. No commit will be called if setCommitCount() was never called, or if setCommitCount(0) was called.

Returns true on success and false if an error occurred.

Note that that default implementation of this method just returns true. Child classes should override this method.

Reimplemented in sqlrimportcsv, sqlrimportfile, and sqlrimportxml.

◆ importEnd()

virtual bool sqlrimport::importEnd ( )
protectedvirtual

This method should be called at the end of the import process.

This implementation just returns true but a child class may override this method to do something else.

At this point, unless specifically set otherwise in an overridden method...

Should return true on success and false if an error occurred and import should stop if this method return false.

◆ importStart()

virtual bool sqlrimport::importStart ( )
protectedvirtual

This method should be called at the beginning of the import process.

This implementation just returns true but a child class may override this method to do something else.

At this point...

Should return true on success and false if an error occurred and import should stop if this method return false.

◆ insertPrimaryKey()

void sqlrimport::insertPrimaryKey ( const char * primarykeycolumnname,
uint32_t primarykeycolumnindex,
const char * primarykeysequence )

Inserts a primary key at "primarykeycolumnindex".

If setIgnoreColumns(false) is set (the default) then "primarykeycolumnname" must be supplied. Otherwise it can be set to NULL or an empty string.

If "primarykeycolumnsequence" is non-empty and non-null then nextval('"primarykeycolumnsequence"') will be used to generate the key. Otherwise a NULL will be used in an attempt to trigger an autoincrement/serial column to generate a key.

◆ insertStaticValue()

void sqlrimport::insertStaticValue ( const char * columnname,
uint32_t columnindex,
const char * value )

Inserts static value "value" at "columnindex" for all rows.

If setIgnoreColumns(false) is set (the default) then "columnname" must be supplied. Otherwise it can be set to NULL or an empty string.

◆ mapColumnName()

void sqlrimport::mapColumnName ( const char * from,
const char * to )

Maps column name "from" to "to". If "to" is NULL then the column is unmapped.

◆ mapFieldValue()

void sqlrimport::mapFieldValue ( const char * from,
const char * to )

Maps field value "from" to "to". If "to" is NULL then the field is unmapped.

◆ removePrimaryKey()

void sqlrimport::removePrimaryKey ( )

Removes any primary key configuaration set by a prior call to insertPrimaryKey().

◆ removeStaticValue()

void sqlrimport::removeStaticValue ( uint32_t columnindex)

Removes any static value configuaration at "columnindex" set by a prior call to insertStaticValue().

◆ rowEnd()

virtual bool sqlrimport::rowEnd ( )
protectedvirtual

This method should be called after the import of each row.

This implementation just returns true but a child class may override this method to do something else.

At this point, unless specifically set otherwise in an overridden method...

Note that this method is called whether or not a row is ignored or excluded. For example... If setIgnoreEmptyRows(true) has been called then this method will still be called for each empty row.

Should return true on success and false if an error occurred and import should stop if this method return false.

◆ rowsEnd()

virtual bool sqlrimport::rowsEnd ( )
protectedvirtual

This method should be called after the import of the rows.

This implementation just returns true but a child class may override this method to do something else.

At this point, unless specifically set otherwise in an overridden method...

Should return true on success and false if an error occurred and import should stop if this method return false.

◆ rowsStart()

virtual bool sqlrimport::rowsStart ( )
protectedvirtual

This method should be called prior to the import of the rows.

This implementation just returns true but a child class may override this method to do something else.

At this point, unless specifically set otherwise in an overridden method...

Should return true on success and false if an error occurred and import should stop if this method return false.

◆ rowStart()

virtual bool sqlrimport::rowStart ( )
protectedvirtual

This method should be called prior to the import of each row.

This implementation just returns true but a child class may override this method to do something else.

At this point, unless specifically set otherwise in an overridden method...

This is a good place to call setExcludeRow(true) if you don't want this row to be imported.

Note that this method is called whether or not a row is ignored or excluded. For example... If setIgnoreEmptyRows(true) has been called then this method will still be called for each empty row.

Should return true on success and false if an error occurred and import should stop if this method return false.

◆ setCoarseLogLevel()

void sqlrimport::setCoarseLogLevel ( uint8_t coarseloglevel)

Sets the coarse log level. General log messages will be logged at this level. If the log level of "lg" (set by setLogger() above) is set equal to or greater than "coarseloglevel" then general log messages will be logged. Defaults to 0.

◆ setCommitCount()

void sqlrimport::setCommitCount ( uint64_t commitcount)

Call commit after every "commitcount" inserts. If set to 0 then no commits will be called and the commit behavior will depend on the behavior of the instance of sqlrelay that we are connecting to. Defaults to 0.

◆ setCurrentColumn()

void sqlrimport::setCurrentColumn ( uint32_t currentcol)
protected

Sets the index of the column that is currently being imported.

Not commonly called by implementations of the *Start/End() methods.

◆ setCurrentColumnName()

void sqlrimport::setCurrentColumnName ( char * currentcolname)
protected

Sets the name of the column that is currently being imported.

Note that "currentcolname" is a char *, not a const char *. Whatever value it is set to will eventually be freed by this class. Set "currentcolname" accordingly.

May be called by columnStart(). Not commonly called by other *Start/End() methods.

◆ setCurrentField()

void sqlrimport::setCurrentField ( char * currentfield)
protected

Sets the value of the field that is currently being imported.

Note that "currentfield" is a char *, not a const char * argument. A buffer must be allocated, populated, and passed in to it, and that buffer will eventually be deallocated by this class. Plan accordingly.

Not commonly called by implementations of the *Start/End() methods.

◆ setCurrentRow()

void sqlrimport::setCurrentRow ( uint64_t currentrow)
protected

Sets the index of the row that is currently being imported.

Not commonly called by implementations of the *Start/End() methods.

◆ setDateDelimiters()

void sqlrimport::setDateDelimiters ( const char * datedelimiters)

If setReformatDateTime(true) has been called, then...

Sets the set of characters that will be used to parse dates to "datedelimiters".

Defaults to NULL which implies "/-.:".

Has no effect if setReformatDateTime(false) has been called or if setReformatDateTime() has never been called.

◆ setDateTimeFormat()

void sqlrimport::setDateTimeFormat ( const char * datetimeformat)

If setReformatDateTime(true) has been called, then...

Sets the format to use when reformatting date/times to "datetimeformat".

Defaults to "YYYY-MM-DD HH24:MI:SS".

Has no effect if setReformatDateTime(false) has been called or if setReformatDateTime() has never been called.

◆ setDbType()

void sqlrimport::setDbType ( const char * dbtype)

Sets the database type, which impacts how things like escaping, sequences, and auto-increment fields are handled. Should be one of "postgresql", "mysql", "firebird", "oracle", "db2", or "informix". Or may be left empty or NULL for generic handling. Defaults to NULL.

◆ setDdMm()

void sqlrimport::setDdMm ( bool ddmm)

If setReformatDateTime(true) has been called, then...

If "ddmm" is set true then date/time fields in formats like xx/xx/xxxx, xx-xx-xxxx, xx.xx.xxxx, etc. will be interpreted as DD/MM/YYYY rather than MM/DD/YYYY.

If "ddmm" is set false then date/time fields in formats like xx/xx/xxxx, xx-xx-xxxx, xx.xx.xxxx, etc. will be interpreted as MM/DD/YYYY rather than MM/DD/YYYY.

Defaults to false.

Has no effect if setReformatDateTime(false) has been called or if setReformatDateTime() has never been called.

◆ setExcludeRow()

void sqlrimport::setExcludeRow ( bool excluderow)
protected

Sets whether the current row will be excluded or not. Rows that are excluded are not imported.

May be called by implementations of rowStart(). Not commonly called by other *Start/End() methods.

◆ setFineLogLevel()

void sqlrimport::setFineLogLevel ( uint8_t fineloglevel)

Sets the fine log level. Detailed log messages will be logged at this level. If the log level of "lg" (set by setLogger() above) is set equal to or greater than "coarseloglevel" then general log messages will be logged. Defaults to 9.

◆ setIgnoreColumns()

void sqlrimport::setIgnoreColumns ( bool ignorecolumns)

If "ignorecolumns" is set false, then column information will be read from the import (eg. from the CSV header, from XML tags inside of the file, etc.) and used to define the column-order of the import data, which may be different from the column-order of the table, and may exclude nullable columns.

If "ignorecolumns" is set true, then any column information included in the import will be ignored. Import data will be assumed to be in the same column-order as the column-order of the table. This is useful, for example, when a CSV header contains different column names than the table.

Defaults to false.

◆ setIgnoreColumnsWithEmptyNames()

void sqlrimport::setIgnoreColumnsWithEmptyNames ( bool ignorecolumnswithemptynames)

If "ignorecolumnswithemptynames" is set true, then columns with empty column names will be completely ignored. It will be as if those columns are completely absent from the CSV, which may be important to keep in mind when specifying indexes for primary keys or static values.

Note that "ignorecolumsnwithemptynames" is observed even if setIgnoreColumns(true) is set.

◆ setIgnoreEmptyRows()

void sqlrimport::setIgnoreEmptyRows ( bool ignoreemptyrows)

Configures the instance to ignore empty rows.

◆ setImportedRowCount()

void sqlrimport::setImportedRowCount ( uint64_t importedrowcount)
protected

Sets the number of rows that have been imported.

Not commonly called by implementations of the *Start/End() methods.

◆ setIsDateTimeColumn()

void sqlrimport::setIsDateTimeColumn ( uint64_t index,
bool datetime )
protected

Sets whether the data type of the column in position "index" is a date/time type or not. If "datetime" is true then the type of the column is set to date/time. If "datetime" is false then the type of the column is set to non-date/time.

Not commonly called by implementations of the *Start/End() methods.

◆ setIsNumericColumn()

void sqlrimport::setIsNumericColumn ( uint64_t index,
bool numeric )
protected

Sets whether the data type of the column in position "index" is a numeric type or not. If "numeric" is true then the type of the column is set to numeric. If "numeric" is false then the type of the column is set to non-numeric.

Not commonly called by implementations of the *Start/End() methods.

◆ setLastCenturyThreshold()

void sqlrimport::setLastCenturyThreshold ( uint16_t lastcenturythreshold)

If setReformatDateTime(true) has been called, then...

Sets the threshold for detecting whether a date that does not contain a century is meant to refer to the current or previous century.

Works in conjunction with setNoCenturyThreshold().

Eg. if set to 10 then

  • any date determined not to have a century that is > 10 years from the current date will be considered to be in the previous century
  • if the current year is 2020 then a date of 10, 20 or 30 will be considered to be 2010, 2020, or 2030
  • a date of 31, 40, 50, etc. will be considered to be 1931, 1940, 1950, etc.

Eg. if set to 0 then

  • all dates will be considered to be in the current century
  • if the current year is 2020, then a date of 10, 20, 30, 40, 50, 100, etc. will be considered to be 2010, 2020, 2030, 2040, 2050, 2100, etc.

Defaults to 10.

Has no effect if setReformatDateTime(false) has been called or if setReformatDateTime() has never been called.

◆ setLogErrors()

void sqlrimport::setLogErrors ( bool logerrors)

If "logerrors" is set true then SQL errors will be logged at the coarse log level. If set false then SQL errors will not be logged. Defaults to false.

◆ setLogger()

void sqlrimport::setLogger ( logger * lg)

Sets the logger to use when logging progress to "lg". If "lg" is set to NULL then progress will not be logged. Defaults to NULL.

◆ setLogIndent()

void sqlrimport::setLogIndent ( uint32_t logindent)

Sets the log indent level to "logindent". Defaults to 0.

◆ setLowerCaseColumnNames()

void sqlrimport::setLowerCaseColumnNames ( )

Lower-cases colum names.

◆ setMixedCaseColumnNames()

void sqlrimport::setMixedCaseColumnNames ( )

Leaves column names as-is.

◆ setNoCenturyThreshold()

void sqlrimport::setNoCenturyThreshold ( uint16_t nocenturythreshold)

If setReformatDateTime(true) has been called, then...

Sets the threshold for detecting that a date does not contain a century.

Works in conjunction with setLastCenturyThreshold().

Eg. if set to 100 then

  • any date who's year component is < 100 will be considered not to have a century
  • a date like 99 or 90 will not be considered to actually be the years 99 or 90, but rather 1999, 1990, 2099, 2099, etc., depending on setLastCenturyThreshold()

Eg. if set to 0 then

  • the date's year component will be taken literally
  • a date like 99 or 90 will be considerd to actually be the year 99 or 90

Defaults to 100.

Has no effect if setReformatDateTime(false) has been called or if setReformatDateTime() has never been called.

◆ setObjectName()

void sqlrimport::setObjectName ( const char * objectname)

By default, the name of the table or sequence to import data into is derived from the import file (eg. from the CSV file name, or from an XML tag inside of the file). This method may be used to explicitly override that name, or provide one if none can be derived.

◆ setReformatDateTime()

void sqlrimport::setReformatDateTime ( bool reformatdatetime)

If "reformatdatetime" is set true then date/time fields will be reformatted prior to import according to rules defined by setDdMm(), setYyyyDdMm(),setDateDelimiters(), setNoCenturyThreshold(), setLastCenturyThreshold(), and setDateTimeFormat().

If "reformatdatetime" is set false then date/time fields will be not reformatted prior to import.

Defaults to false.

◆ setSqlrConnection()

void sqlrimport::setSqlrConnection ( sqlrconnection * sqlrcon)

Sets the instance of sqlrconnection that this instance will use to insert data for the import.

◆ setSqlrCursor()

void sqlrimport::setSqlrCursor ( sqlrcursor * sqlrcur)

Sets the instance of sqlrcursor that this instance will use to insert data for the import.

◆ setUpperCaseColumnNames()

void sqlrimport::setUpperCaseColumnNames ( )

Upper-cases colum names.

◆ setYyyyDdMm()

void sqlrimport::setYyyyDdMm ( bool yyyyddmm)

If setReformatDateTime(true) has been called, then...

If "yyyyddmm" is set true then date/time fields in formats like xxxx/xx/xx, xxxx-xx-xx, xxxx.xx.xx, etc. will be interpreted as YYYY/DD/MM rather than YYYY/MM/DD.

If "yyyyddmm" is set false then date/time fields in formats like xxxx/xx/xx, xxxx-xx-xx, xxxx.xx.xx, etc. will be interpreted as YYYY/MM/DD rather than YYYY/MM/DD.

Defaults to false.

Has no effect if setReformatDateTime(false) has been called or if setReformatDateTime() has never been called.