Search by Tags

Cloud Rds Lib API

 

Article updated at 28 Oct 2017

Attention: this is a legacy library and thus not supported by Toradex anymore. We recommend that you use the new libraries for all Toradex modules. Please see the Toradex CE Libraries and Code Samples for up-to-date information.

Contains function declarations to be used to access MySQL Server. Target Modules are Colibri Modules [PXAxxx, Tegra T20, Tegra T30], WinCE 6.0 / 7.0 . More...

Data Structures

struct  mysql

Macros

#define  MYSQL_ERROR_STRING_LENGTH  256
#define  MYSQL_INSTANCE_ENDPOINT_LENGTH  64
#define  MYSQL_USER_NAME_LENGTH  64
#define  MYSQL_USER_PASSWORD_LENGTH  64
#define  MYSQL_QUERY_STRING_LENGTH  256
#define  FILENAME_BUFFER_SIZE  128
#define  DATA_SEND_BUFFER_SIZE  1024
#define  DATA_RECEIVE_BUFFER_SIZE  1024

Typedefs

typedef struct mysql MYSQL

Functions

BOOL  MySqlOpen (MYSQL *mysqlAccount, const CHAR *sqlInstanceEndpoint, const CHAR *sqlUserName, const CHAR *sqlUserPassword)
BOOL  MySqlConnect (MYSQL mysqlAccount, WORD mysqlPortNumber)
BOOL  MySqlConnectWithSsl (MYSQL mysqlAccount, WORD mysqlPortNumber)
BOOL  MySqlRowQuery (MYSQL mysqlAccount, const CHAR *mysqlQuery, const CHAR *resultFilePath, DWORD *columnsInTable)
BOOL  MySqlClose (MYSQL *mysqlAccount)
BOOL  MySqlQuit (MYSQL mysqlAccount)
BOOL  MySqlInitDb (MYSQL mysqlAccount, const CHAR *schemaName)
BOOL  MySqlListFields (MYSQL mysqlAccount, const CHAR *tableName, const CHAR *resultFilePath, DWORD *columnsInTable)
BOOL  MySqlCreateDb (MYSQL mysqlAccount, const CHAR *createDbStatement)
BOOL  MySqlDropDb (MYSQL mysqlAccount, const CHAR *schemaName)
BOOL  MySqlPing (MYSQL mysqlAccount)
BOOL  MySqlUpdateQuery (MYSQL mysqlAccount, const CHAR *updateQuery)
BOOL  MySqlInsertQuery (MYSQL mysqlAccount, const CHAR *insertQuery)
BOOL  MySqlDeleteQuery (MYSQL mysqlAccount, const CHAR *deleteQuery)
DWORD  MySqlAffectedRows (MYSQL mysqlAccount)
BOOL  MySqlAlterQuery (MYSQL mysqlAccount, const CHAR *alterQuery)
BOOL  MySqlGetNumberOfRows (MYSQL mysqlAccount, const CHAR *tableName, DWORD *numberOfRows)
BOOL  MySqlListTables (MYSQL mysqlAccount, const CHAR *dbInstanceName, const CHAR *filePath)
void  MySqlClearError (MYSQL mysqlAccount)
BOOL  MySqlCreateViewQuery (MYSQL mysqlAccount, const CHAR *viewQuery)
BOOL  MySqlPrepareStatementQuery (MYSQL mysqlAccount, const CHAR *prepareQuery, DWORD *statementId, DWORD *numberOfParamters)
BOOL  MySqlPrepareSendLongData (MYSQL mysqlAccount, DWORD statementId, DWORD parameterId, const CHAR *dataForPrepareQuery)
BOOL  MySqlStatementExecute (MYSQL mysqlAccount, DWORD statementId, DWORD numberOfParameters, DWORD optionFlags)
BOOL  MySqlPrepareStatementClose (MYSQL mysqlAccount, DWORD statementId)
BOOL  MySqlPrepareStatementReset (MYSQL mysqlAccount, DWORD statementId)
BOOL  MySqlSetMultiStatementOption (MYSQL mysqlAccount, BOOL multiStatementOn)
BOOL  MySqlStatementFetch (MYSQL mysqlAccount, DWORD statementId)

Detailed Description

Contains function declarations to be used to access MySQL Server. Target Modules are Colibri Modules [PXAxxx, Tegra T20, Tergra T30], WinCE 6.0 / 7.0 .

Author:
Rev:
Date:
2014-01-08 10:00:00 +0530 (Wed, 08 Jan 2014)

Function Documentation

DWORD MySqlAffectedRows ( MYSQL mysqlAccount )

Returns the number of rows changed, deleted, or inserted

Parameters
[in] mysqlAccount Handle returned by call to MySqlOpen()
Return values
Number of rows affected Contains valid value only after successful calls to MySqlUpdate(), MySqlInsert() or MySqlDelete()
BOOL MySqlAlterQuery ( MYSQL mysqlAccount,
const CHAR *  alterQuery
)

Add, Delete or Modify columns in the table

Parameters
[in] mysqlAccount Handle returned by call to MySqlOpen()
[in] alterQuery MySQL ALTER query statement For example: "ALTER TABLE mysqldb.TestDbTable ADD Column3 int" where mysqldb is the schema/database name and TestDbTable is the table name
Return values
TRUE Success
FALSE See WSAGetLastError() and GetLastError()
void MySqlClearError ( MYSQL mysqlAccount )

Clears the MySQL error number and error string

Parameters
[in] mysqlAccount Handle returned by call to MySqlOpen()
Return values
BOOL MySqlClose ( MYSQL mysqlAccount )

Close the handle for the MySQL connection

Parameters
[in] mysqlAccount Handle returned by call to MySqlOpen()
Return values
TRUE Success
FALSE See WSAGetLastError()
BOOL MySqlConnect ( MYSQL mysqlAccount,
WORD  mysqlPortNumber
)

Opens a connection to the Amazon RDS MySQL instance

Parameters
[in] mysqlAccount Handle returned by call to MySqlOpen()
[in] mysqlPortNumber Port number on which to communicate with the Amazon RDS MySQL instance If specified as 0, default MySQL port number of 3306 will be used
Return values
TRUE Success
FALSE See GetLastError() and WSAGetLastError()
BOOL MySqlConnectWithSsl ( MYSQL mysqlAccount,
WORD  mysqlPortNumber
)

Open a conenction to the Amazon RDS MySQL instance using SSL

Parameters
[in] mysqlAccount Handle returned by call to MySqlOpen()
[in] mysqlPortNumber Port number on which to communicate with the Amazon RDS MySQL instance If specified as 0, default MySQL port number of 3306 will be used
Return values
TRUE Success
FALSE See GetLastError() and WSAGetLastError()
BOOL MySqlCreateDb ( MYSQL mysqlAccount,
const CHAR *  createDbStatement
)

Create a new schema/database

Parameters
[in] mysqlAccount Handle returned by call to MySqlOpen()
[in] createDbStatement MySQL CREATE_DATABASE statement Example: "CREATE TABLE mysqldb.TestDbTable(Column1 int primary key auto_increment, Column2 int)" where "mysqldb" is the schema/database name and "TestDbTable" is the table name
Return values
TRUE Success
FALSE See WSAGetLastError() and GetLastError()
BOOL MySqlCreateViewQuery ( MYSQL mysqlAccount,
const CHAR *  viewQuery
)

Create views for the database table

Parameters
[in] mysqlAccount Handle returned by call to MySqlOpen()
[in] viewQuery MySQL View query statement Example: CREATE VIEW view_name AS SELECT column_name(s) FROM table_name WHERE condition
Return values
TRUE Success
FALSE See WSAGetLastError() and GetLastError() To be implemented
BOOL MySqlDeleteQuery ( MYSQL mysqlAccount,
const CHAR *  deleteQuery
)

Delete data in the table

Parameters
[in] mysqlAccount Handle returned by call to MySqlOpen()
[in] deleteQuery MySQL DELETE query statement For example: "DELETE FROM mysqldb.TestDbTable WHERE Column1 = 900" where mysqldb is the schema/database name and TestDbTable is the table name
Return values
TRUE Success
FALSE See WSAGetLastError() and GetLastError()
BOOL MySqlDropDb ( MYSQL mysqlAccount,
const CHAR *  schemaName
)

Drop a schema/database

Parameters
[in] mysqlAccount Handle returned by call to MySqlOpen()
[in] schemaName Name of the schema/database to drop Example: "mysqldb.TestDbTable" where "mysqldb" is the schema/database name and "TestDbTable" is the table name
Return values
TRUE Success
FALSE See WSAGetLastError() and GetLastError()
BOOL MySqlGetNumberOfRows ( MYSQL mysqlAccount,
const CHAR *  tableName,
DWORD *  numberOfRows
)

Get the number of records in the table

Parameters
[in] mysqlAccount Handle returned by call to MySqlOpen()
[in] tableName Table name for which number of records has to be retrieved Example: "mysqldb.TestDbTable" where "mysqldb" is the schema/database name and "TestDbTable" is the table name
[out] numberOfRows Number of records in the table
Return values
TRUE Success
FALSE See WSAGetLastError() and GetLastError()
BOOL MySqlInitDb ( MYSQL mysqlAccount,
const CHAR *  schemaName
)

Change the default schema of the connection

Parameters
[in] mysqlAccount Handle returned by call to MySqlOpen()
[in] schemaName Name of the schema to change to
Return values
TRUE Success
FALSE See WSAGetLastError() and GetLastError()
BOOL MySqlInsertQuery ( MYSQL mysqlAccount,
const CHAR *  insertQuery
)

Insert data in the table

Parameters
[in] mysqlAccount Handle returned by call to MySqlOpen()
[in] insertQuery MySQL INSERT query statement For example: "INSERT INTO mysqldb.TestDbTable (Column1, Column2) VALUES(900, 1000)" where mysqldb is the schema/database name and TestDbTable is the table name
Return values
TRUE Success
FALSE See WSAGetLastError() and GetLastError()
BOOL MySqlListFields ( MYSQL mysqlAccount,
const CHAR *  tableName,
const CHAR *  resultFilePath,
DWORD *  columnsInTable
)

Get the column definitions of a table

Parameters
[in] mysqlAccount Handle returned by call to MySqlOpen()
[in] tableName Table name for which column definition has to be retrieved Example: "mysqldb.TestDbTable" where "mysqldb" is the schema/database name and "TestDbTable" is the table name
[in] resultFilePath Pointer to the local file path string in which result will be stored
[out] columnsInTable Number of columns in the table
Return values
TRUE Success
FALSE See WSAGetLastError() and GetLastError() Data will be in the following format: Field Type Null Key Default Extra
BOOL MySqlListTables ( MYSQL mysqlAccount,
const CHAR *  dbInstanceName,
const CHAR *  filePath
)

List tables in the database

Parameters
[in] mysqlAccount Handle returned by call to MySqlOpen()
[in] dbInstanceName Name of the MySQL database instance
[in] filePath Pointer to the local file path string in which result will be stored
Return values
TRUE Success
FALSE See WSAGetLastError() and GetLastError()
BOOL MySqlOpen ( MYSQL mysqlAccount,
const CHAR *  sqlInstanceEndpoint,
const CHAR *  sqlUserName,
const CHAR *  sqlUserPassword
)

Opens a handle for the MySQL connection

Parameters
[out] mysqlAccount Amazon RDS MySQL instance account handle
[in] sqlInstanceEndpoint Endpoint address of the Amazon RDS MySQL instance
[in] sqlUserName User name of the Amazon RDS MySQL instance
[in] sqlUserPassword Password for the Amazon RDS MySQL instance
Return values
TRUE Success
FALSE See GetLastError()
BOOL MySqlPing ( MYSQL mysqlAccount )

Check if the server connection is alive

Parameters
[in] mysqlAccount Handle returned by call to MySqlOpen()
Return values
TRUE Success
FALSE See WSAGetLastError() and GetLastError()
BOOL MySqlPrepareSendLongData ( MYSQL mysqlAccount,
DWORD  statementId,
DWORD  parameterId,
const CHAR *  dataForPrepareQuery
)

Send data for a prepared statement

Parameters
[in] mysqlAccount Handle returned by call to MySqlOpen()
[in] statementId Statement Id returned from a previous call to MySqlPrepareQuery()
[in] parameterId Parameter Id for the data
[in] dataForPrepareQuery Data for the prepare query
Return values
TRUE Success
FALSE See WSAGetLastError() and GetLastError() Must be called before MySqlPrepareStatementExecute() To be implemented
BOOL MySqlPrepareStatementClose ( MYSQL mysqlAccount,
DWORD  statementId
)

Deallocates a prepare statement query

Parameters
[in] mysqlAccount Handle returned by call to MySqlOpen()
[in] statementId Statement Id returned by call to MySqlPrepareQuery()
Return values
TRUE Success
FALSE See WSAGetLastError() and GetLastError() To be implemented
BOOL MySqlPrepareStatementQuery ( MYSQL mysqlAccount,
const CHAR *  prepareQuery,
DWORD *  statementId,
DWORD *  numberOfParamters
)

Create a prepared statement

Parameters
[in] mysqlAccount Handle returned by call to MySqlOpen()
[in] preparQuery MySQL prepare query statement
[out] statementId Statement ID use to identify the prepare statement
[out] numberOfParameters Number of Parameters
Return values
TRUE Success
FALSE See WSAGetLastError() and GetLastError() To be implemented
BOOL MySqlPrepareStatementReset ( MYSQL mysqlAccount,
DWORD  statementId
)

Reset the data of a prepared statement which was accumulated with MySqlPrepareSendLongData()

Parameters
[in] mysqlAccount Handle returned by call to MySqlOpen()
[in] statementId Statement Id returned by call to MySqlPrepareQuery()
Return values
TRUE Success
FALSE See WSAGetLastError() and GetLastError() To be implemented
BOOL MySqlQuit ( MYSQL mysqlAccount )

Close the connection to the Amazon RDS MySQL instance

Parameters
[in] mysqlAccount Handle returned by call to MySqlOpen()
Return values
TRUE Success
FALSE See WSAGetLastError() and GetLastError()
BOOL MySqlRowQuery ( MYSQL mysqlAccount,
const CHAR *  mysqlQuery,
const CHAR *  resultFilePath,
DWORD *  columnsInTable
)

Query the rows of Amazon RDS MySQL instance

Parameters
[in] mysqlAccount Handle returned by call to MySqlOpen()
[in] mysqlQuery MySQL SELECT Query statement For example: "SELECT * FROM mysqldb.TestDbTable" where mysqldb is the schema/database name and TestDbTable is the MySQL table name
[in] resultFilePath Pointer to the local file path string in which result of MySQL query will be stored
[out] columnsInTable Number of columns in the table
Return values
TRUE Success
FALSE See WSAGetLastError() and GetLastError()
BOOL MySqlSetMultiStatementOption ( MYSQL mysqlAccount,
BOOL  multiStatementOn
)

Set Multi statement operation

Parameters
[in] mysqlAccount Handle returned by call to MySqlOpen()
[in] multiStatementOn TRUE: Multi statements ON, FALSE: Multi statements OFF
Return values
TRUE Success
FALSE See WSAGetLastError() and GetLastError() To be implemented
BOOL MySqlStatementExecute ( MYSQL mysqlAccount,
DWORD  statementId,
DWORD  numberOfParameters,
DWORD  optionFlags
)

Execute a statement query

Parameters
[in] mysqlAccount Handle returned by call to MySqlOpen()
[in] statementId Statement Id returned by call to MySqlPrepareQuery()
[in] numberOfParameters Number of parameters returned by call to MySqlPrepareQuery()
[in] optionFlags Option flags for prepare statment execution
Return values
TRUE Success
FALSE See WSAGetLastError() and GetLastError() To be implemented
BOOL MySqlStatementFetch ( MYSQL mysqlAccount,
DWORD  statementId
)

Fetch a row from a existing resultset after a COM_STMT_EXECUTE.

Parameters
[in] mysqlAccount Handle returned by call to MySqlOpen()
[in] statementId Statement Id of a stored procedure
Return values
TRUE Success
FALSE See WSAGetLastError() and GetLastError() To be implemented
BOOL MySqlUpdateQuery ( MYSQL mysqlAccount,
const CHAR *  updateQuery
)

Update data in the table

Parameters
[in] mysqlAccount Handle returned by call to MySqlOpen()
[in] updateQuery MySQL UPDATE query statement For example: "UPDATE mysqldb.TestDbTable SET Column2 = 1001 WHERE Column1 = 900" where mysqldb is the schema/database name and TestDbTable is the table name
Return values
TRUE Success
FALSE See WSAGetLastError() and GetLastError()