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

Inherited by sqlrimportcsv, and sqlrimportxml.

Public Member Functions

 sqlrimport ()
 
virtual ~sqlrimport ()
 
void setSqlrConnection (sqlrconnection *sqlrcon)
 
void setSqlrCursor (sqlrcursor *sqlrcur)
 
void setDbType (const char *dbtype)
 
void setObjectName (const char *objectname)
 
void setIgnoreColumns (bool ignorecolumns)
 
void mapColumnName (const char *from, const char *to)
 
void mixedCaseColumnNames ()
 
void lowerCaseColumnNames ()
 
void upperCaseColumnNames ()
 
void mapFieldValue (const char *from, const char *to)
 
void setCommitCount (uint64_t commitcount)
 
void setLogger (logger *lg)
 
void setCoarseLogLevel (uint8_t coarseloglevel)
 
void setFineLogLevel (uint8_t fineloglevel)
 
void setLogIndent (uint32_t logindent)
 
void setLogErrors (bool logerrors)
 
virtual bool importFromFile (const char *filename)=0
 

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

◆ importFromFile()

virtual bool sqlrimport::importFromFile ( const char *  filename)
pure virtual

Imports data from "filename". The table (or sequence) to import the data into will be derived from the import file (eg. from the CSV file name, or from an XML tag inside of the file) or may be overridden using setObjectName() above.

Implemented in sqlrimportxml, and sqlrimportcsv.

◆ lowerCaseColumnNames()

void sqlrimport::lowerCaseColumnNames ( )

Lower-cases colum names.

◆ 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.

◆ mixedCaseColumnNames()

void sqlrimport::mixedCaseColumnNames ( )

Leaves column names as-is.

◆ 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.

◆ 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.

◆ 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 file (eg, from the CSV header, or from XML tags inside of the file) 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 file 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.

◆ 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 instance to use. If set to NULL then no logging will be done. Defaults to NULL.

◆ setLogIndent()

void sqlrimport::setLogIndent ( uint32_t  logindent)

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

◆ 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.

◆ setSqlrConnection()

void sqlrimport::setSqlrConnection ( sqlrconnection sqlrcon)

Sets the instance of sqlrconnection that this instance will use to connect to the database.

◆ setSqlrCursor()

void sqlrimport::setSqlrCursor ( sqlrcursor sqlrcur)

Sets the instance of sqlrcursor that this instance will use to run queries.

◆ upperCaseColumnNames()

void sqlrimport::upperCaseColumnNames ( )

Upper-cases colum names.