![]() |
mksqlite
2.5
A MATLAB interface to SQLite
|
SQLite interface. More...
#include <sql_interface.hpp>
Classes | |
struct | to_alphanum |
Converts one char to a printable (non-white-space) character. More... | |
Public Member Functions | |
SQLiface (SQLstackitem &stackitem) | |
Standard ctor. | |
~SQLiface () | |
Dtor. | |
bool | isOpen () |
Returns true, if database is open. | |
void | clearErr () |
Clear recent error message. | |
const char * | getErr (const char **errid=NULL) |
Get recent error message. | |
void | setErr (int err_id) |
Sets an error by its ID (see MSG_IDS) | |
void | setSqlError (int rc) |
Sets an error by its SQL return code. | |
bool | errPending () |
Returns true, if an unhandled error is pending. | |
const char * | getDbFilename (const char *database) |
Get the filename of current database. | |
bool | setBusyTimeout (int iTimeoutValue) |
Sets the busy timemout in milliseconds. | |
bool | getBusyTimeout (int &iTimeoutValue) |
Returns the busy timeout in milliseconds. | |
bool | setEnableLoadExtension (int flagOnOff) |
Enable or disable load extensions. | |
void | closeStmt () |
Closing current statement. | |
bool | attachMexFunction (const char *name, const ValueMex &func, const ValueMex &step, const ValueMex &final, ValueMex &exception) |
Attach application-defined function to database object. | |
bool | setQuery (const char *query) |
Dispatch a SQL query. More... | |
int | getParameterCount () |
Returns the count of parameters the current statement expects. | |
const char * | getParameterName (int n) |
Returns the name for nth parameter. | |
long | getLastRowID () |
kv69: Returns the number of last row id; usefull for inserts in tables with autoincrement primary keys | |
void | clearBindings () |
Clears all parameter bindings from current statement. | |
bool | bindParameter (int index, const ValueMex &item, bool bStreamable) |
Binds one parameter from current statement to a MATLAB array. More... | |
int | step () |
Evaluates current SQL statement. | |
int | colCount () |
Returns the column count for current statement. | |
int | colType (int index) |
Returns the (prefered) type of one column for current statement. More... | |
sqlite3_int64 | colInt64 (int index) |
Returns an integer value for least fetch and column number. | |
double | colFloat (int index) |
Returns a floating point value for least fetch and column number. | |
const unsigned char * | colText (int index) |
Returns a text value for least fetch and column number. | |
const void * | colBlob (int index) |
Returns a BLOB for least fetch and column number. | |
size_t | colBytes (int index) |
Returns the size of one value of least fetch and column number in bytes. | |
const char * | colName (int index) |
Returns the column name least fetch and column number. | |
int | getColNames (ValueSQLCol::StringPairList &names) |
Returns the column names of least fetch. More... | |
void | reset () |
Reset current SQL statement. | |
void | finalize () |
Clear parameter bindings and finalize current statement. | |
bool | fetch (ValueSQLCols &cols, bool initialize=false) |
Proceed a table fetch. More... | |
Static Public Member Functions | |
static void | mexFcnWrapper_FCN (sqlite3_context *ctx, int argc, sqlite3_value **argv) |
Wrapper for SQL function. | |
static void | mexFcnWrapper_STEP (sqlite3_context *ctx, int argc, sqlite3_value **argv) |
Wrapper for SQL step function (aggregation) | |
static void | mexFcnWrapper_FINAL (sqlite3_context *ctx) |
Wrapper for SQL final function (aggregation) | |
static void | mexFcnWrapper (sqlite3_context *ctx, int argc, sqlite3_value **argv, int func_nr) |
Common wrapper for all user defined SQL functions. | |
Private Attributes | |
SQLstackitem * | m_pstackitem |
pointer to current database | |
sqlite3 * | m_db |
SQLite db handle. | |
const char * | m_command |
SQL query (no ownership, read-only!) | |
sqlite3_stmt * | m_stmt |
SQL statement (sqlite bridge) | |
SQLerror | m_lasterr |
recent error message | |
Friends | |
class | SQLerror |
SQLite interface.
Encapsulates one sqlite object with pending command and statement.
Definition at line 558 of file sql_interface.hpp.
|
inline |
Binds one parameter from current statement to a MATLAB array.
[in] | index | Parameter number (0 based) |
[in] | item | MATLAB array |
[in] | bStreamable | true, if streaming is possible and desired |
Definition at line 1135 of file sql_interface.hpp.
|
inline |
Returns the (prefered) type of one column for current statement.
[in] | index | Index number of desired column (0 based) |
Definition at line 1254 of file sql_interface.hpp.
|
inline |
Proceed a table fetch.
[out] | cols | Column vectors to collect results |
[in] | initialize | Initializing cols if set (only on first call of fetch() when parameter wrapping is on) |
Stepping through the results and stores the results in column vectors.
Definition at line 1432 of file sql_interface.hpp.
References ValueMex::Data(), g_convertUTF8, ValueMex::Item(), SQLerror::setSqlError(), and utils_strnewdup().
|
inline |
Returns the column names of least fetch.
The column names are used as field names in MATLAB arrays. MATLAB doesn't permit all characters in field names, moreover fieldnames must be unambiguous. So there is a second name which is used to be that fieldname. Column name and field name are represented by string pairs.
[out] | names | String pair list for column names |
Definition at line 1330 of file sql_interface.hpp.
References g_check4uniquefields, and g_namelengthmax.
|
inline |
Dispatch a SQL query.
[in] | query | String containing SQL statement |
Definition at line 1062 of file sql_interface.hpp.