EXASockets  0.9
Interface to the EXASOL DB via JSON over Websockets protocol
exasockets_connection Class Reference

Public Member Functions

  exasockets_connection (const char *server, uint16_t port, const char *clientName, const char *username, const char *password, int pwd_len, bool autocommit=true, bool use_compression=false, uint64_t sessionId=0, bool debug=false)
  Establishes a connection to EXASOL and returns an exasockets_connection object. More...
 
int  disconnect (bool throw_message=true)
  Disconnect from EXASOL DB. More...
 
int update_session_attributes ()
 
virtual exaResultSetHandler *  exec_sql (char *sql)
  Sends an SQL statement to EXASOL and fetches the response. More...
 
int64_t  fetch (exaResultSetHandler *rs, uint64_t numRows=10000, uint64_t startPosition=1, uint64_t numBytes=10485760)
  Fetches a result set. More...
 
virtual int  close_result_set (exaResultSetHandler &rs)
  Closes a result set. More...
 
virtual int  close_result_set (int handle)
  Closes a result set. More...
 
virtual exaResultSetHandler *  create_prepared_insert (char *sql)
  Creates a prepared statement. More...
 
virtual int  create_prepared_insert_int (char *sql)
 
virtual void  exec_prepared_insert (exaResultSetHandler &rs)
  Executes a previously prepared statement. More...
 
virtual int  close_prepared (exaResultSetHandler &rs)
  Closes a prepared statement. More...
 
const char *  databaseName () const
 
const char *  identifierQuoteString () const
 
int  maxDataMessageSize () const
 
int  maxIdentifierLength () const
 
int  maxVarcharLength () const
 
const char *  productName () const
 
int  protocolVersion () const
 
const char *  releaseVersion () const
 
uint64_t  session_id () const
 
const char *  timezone () const
 
const char *  timeZoneBehaviour () const
 
bool  isStatus () const
 

Static Public Member Functions

static int  StringToExaDatatype (const char *str)
 
static char *  ExaDatatypeToString (const int type)
 

Public Attributes

rapidjson::Document resultSet
 
rapidjson::Value *  data
 
bool  json_debug_output = false
 

Protected Member Functions

int  ws_send_data (const char *data, int len=-1, int type=1)
 
std::string  ws_receive_data ()
 

Static Protected Member Functions

static void  append_data_from_Rapid_JSON_Document (exaResultSetHandler *rs, const rapidjson::Value &JSONdata)
 
static exaResultSetHandler *  create_exaResultSetHandler_from_RapidJSON_Document (const rapidjson::Value &JSONresultSet, int handle=-1)
 

Protected Attributes

Websockets_connection *  ws_con = nullptr
 
rapidjson::Document  d
 
std::stringstream  tfile
 
char *  logfile = nullptr
 
const char *  c_databaseName
 
const char *  c_identifierQuoteString
 
int  c_maxDataMessageSize
 
int  c_maxIdentifierLength
 
int  c_maxVarcharLength
 
const char *  c_productName
 
int  c_protocolVersion
 
const char *  c_releaseVersion
 
uint64_t  c_session_id
 
const char *  c_timezone
 
const char *  c_timeZoneBehaviour
 
bool  status
 

Constructor & Destructor Documentation

exasockets_connection::exasockets_connection ( const char *  server,
uint16_t  port,
const char *  clientName,
const char *  username,
const char *  password,
int  pwd_len,
bool  autocommit = true,
bool  use_compression = false,
uint64_t  sessionId = 0,
bool  debug = false 
)

Establishes a connection to EXASOL and returns an exasockets_connection object.

Parameters
serverThe IP address of the EXASOL node to connect to. E.g. '192.168.137.10'
portThe Port the EXASOL DB listens on. E.g. 8563
clientNameThe name of the client, as it will be shown e.g. in the CLIENT column in EXA_(USER/ALL/DBA)_SESSIONS. E.g. the name of the frontend.
usernameThe EXASOL DB user name for authentification. E.g. 'sys'
passwordThe EXASOL user password. E.g. 'exasol'. Transfer is always RSA encrypted.
pwd_lenThe password length. E.g. 6.
autocommitIf the DBMS is supposed to execute a COMMIT automatically after each statement. Default: true (recommended)
use_compressionIf the result sets are to be transferred compressed. Default: false. Compression is not yet implemented on the client side.
sessionIdAn ID for the session to be created in EXASOL. Per default a random session ID is created (recommended).
debug A boolean that controls debug output. If true, all sent and received JSON elements are written to stdout. Default: false
Returns
An exasockets_connection object containing an open connection.

Member Function Documentation

int exasockets_connection::close_prepared ( exaResultSetHandler &  rs )
virtual

Closes a prepared statement.

Sends to the DB the command to close the prepared statement.

Parameters
rs A reference to an exaResultSetHandler object related to the result set to be closed.
Returns
0 on success.
int exasockets_connection::close_result_set ( exaResultSetHandler &  rs )
virtual

Closes a result set.

Sends to the DB the command to dispose the result set.

Parameters
rs A reference to an exaResultSetHandler object related to the result set to be closed.
Returns
0 on success.
int exasockets_connection::close_result_set ( int  handle )
virtual

Closes a result set.

Sends to the DB the command to dispose the result set.

Parameters
handle An exaResultSetHandler object related to the result set to be closed.
Returns
0 on success.
exaResultSetHandler * exasockets_connection::create_prepared_insert ( char *  sql )
virtual

Creates a prepared statement.

Sends to the DB the command to prepare a statement.

Parameters
sql A character string containing the SQL statement to prepare.
Returns
Returns an exaResultSetHandler referencing the prepared statement.
int exasockets_connection::disconnect ( bool  throw_message = true )

Disconnect from EXASOL DB.

If the connection is still alive, a clean disconnect from EXASOL DB is performed.

Parameters
throw_message If true, a status message is thrown to stdout.
Returns
0 in case of success; 1 if EXASOL refuses to disconnect; -1 if the connection had already been dead.
void exasockets_connection::exec_prepared_insert ( exaResultSetHandler &  rs )
virtual

Executes a previously prepared statement.

Sends to the DB the command to execute a previously prepared statement.

Parameters
rs An exaResultSetHandler affiliated with the statement prepared.
exaResultSetHandler * exasockets_connection::exec_sql ( char *  sql )
virtual

Sends an SQL statement to EXASOL and fetches the response.

Sends an SQL stmt and fetches the result set. If a result set handle is received instead of data, then this is returned as an int. Otherwise 0 is returned and the resultSet is stored inside the connection object.

Parameters
sqlThe SQL statement, e.g. 'select * from schema1.tbl1'
Returns
A result handler to be used with fetch() if available, otherwise 0.
int64_t exasockets_connection::fetch ( exaResultSetHandler *  rs,
uint64_t  numRows = 10000,
uint64_t  startPosition = 1,
uint64_t  numBytes = 10485760 
)

Fetches a result set.

Takes a result set handle ID and fetches a result set, to be stored in the object->data.

Parameters
rs An exaResultSetHandler object to be filled with data.
resultSetHandle The id of the result set.
numRows Amount of rows to fetch. Default: 10 000
startPosition row offset from which to begin data retrieval (first row of the table: row 1). Default: 1
numBytes Number of bytes to retrieve. Default: 10 485 760 (10 MB)
Returns
the number of rows fetched.

The documentation for this class was generated from the following files: