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

#include <sqlrimportfile.h>

Inherits sqlrimport.

Inherited by sqlrimportcsv [virtual], and sqlrimportxml [virtual].

Public Member Functions

 sqlrimportfile ()
 
virtual ~sqlrimportfile ()
 
void setFileName (const char *filename)
 
const char * getFileName ()
 
bool importData ()
 
- Public Member Functions inherited from sqlrimport
 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 ()
 
uint64_t getImportedRowCount ()
 

Protected Member Functions

void setFileDescriptor (filedescriptor *fd)
 
filedescriptor * getFileDescriptor ()
 
- Protected Member Functions inherited from sqlrimport
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 sqlrimportfile class provides a base class for child classes that wish to implement import of data from a database, via SQL Relay, to a file. It provides various common methods. Each child class should implement the importData() method.

Constructor & Destructor Documentation

◆ sqlrimportfile()

sqlrimportfile::sqlrimportfile ( )

Creates an instance of the sqlrimportfile class.

◆ ~sqlrimportfile()

virtual sqlrimportfile::~sqlrimportfile ( )
virtual

Destroys this instance of the sqlrimportfile class.

Member Function Documentation

◆ getFileDescriptor()

filedescriptor * sqlrimportfile::getFileDescriptor ( )
protected

Gets the file descriptor from which data is being imported.

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

◆ getFileName()

const char * sqlrimportfile::getFileName ( )

Gets the name of the file from which data will be be imported.

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

◆ importData()

bool sqlrimportfile::importData ( )
virtual

Imports data from the file set by the most recent call to setFileName() or from standard input if setFileName() was never called or setFileName(NULL) was called.

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 the default implementation of this method just returns true. Child classes that support export to a file should override this method.

Reimplemented from sqlrimport.

Reimplemented in sqlrimportxml.

◆ setFileDescriptor()

void sqlrimportfile::setFileDescriptor ( filedescriptor * fd)
protected

Sets the file descriptor from which data is being imported.

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

◆ setFileName()

void sqlrimportfile::setFileName ( const char * filename)

Sets the name of the file from which data will be imported. If "filename" is NULL the data will be imported from standard input.

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