sqlite3 function interface

sqlite3 function interface (emphasis ★):

int sqlite3_open (const char *, sqlite3 **);
function is used to open / create a library
const char * filename specified, sqlite3 ** specified database handle, the user database handle database operations
return an integer error code, code = 0 on success,> 0 wrong

int sqlite3_close (sqlite3 *);
close the database file, the database parameter is the handle

int sqlite3_exec (sqlite3 *, const char * sql, sqlite_callback, void *, char ** );
function is used to perform one or more SQL statements, with between SQL statement ";" spaced
sqlite3 * specified database handles open, const char * sql specified SQL commands, sqlite_callback SQL execution may be obtained in the callback function As a result, detailed error information passed to the callback function specified void * data, char ** specified command execution failed
returns 0 sql instruction completes, otherwise explain the execution was not successful

int sqlite3_get_table (
  sqlite3 * db, / * An Open Database * /
  const char * ZSQL, / * BE EVALUATED external link to SQL * /
  char *** pazResult, / * Results of at The Query * /
  * pnRow int, / * Number The Result of rows written here Wallpaper * /
  int * pnColumn, / * Number The Result of Columns written here Wallpaper * /
  char ** pzErrmsg / MSG written here Wallpaper * Error * /
);
sqlite3_get_table is mainly used for non callback way to select query
db pointer to open the database obtained, zSql a sql statement like sqlite3_exec, the data query results pazResult, he is an array of pointers, memory distribution: the field name, followed by followed by the value of each field , pnRow query to the number of data (number of rows), pnColumn to the query (number of columns) field, pzReemsg error;
return 0 or other

void sqlite3_free_table (char ** result);
for releasing the contents of the array of pointers to save the query

sqlite_callback int (
    void * PV, / * of the sqlite3_exec () is passed from the fourth parameter * /
    int argc, / * number of columns in the table * /
    char ** the argv, / * array of pointers pointing to the query result, may be made sqlite3_column_text () obtained * /
    char ** col / * array of pointers to the header names can () * obtained from sqlite3_column_name /
);
Return Value: 1 interrupt it to 0 to continue to include the query data


there are 2 (minor):

const char * sqlite3_errmsg (sqlite3 *);
return error codes corresponding to the text, the parameter is a handle to a database

void sqlite3_free (void *);
 release memory space to store the error message, sqlite3_errmsg returned by this function must be released errmsg

Guess you like

Origin www.cnblogs.com/zx0722/p/11314397.html