C. API function of SQLite
Embedded database SQLite provides API interface of C
language, making operation of the database is very simple.
Some of the functions will be introduced briefly in the
following paper[4]:
1) C/C++ common interface of SQLite3
typedef struct sqlite3 sqlite3;
int sqlite3_open(const char*, sqlite3**); //open the
database, including documents and memory database.
int sqlite3_close(sqlite3*); //close the database
int qlite3_last_insert_rowid(sqlite3*); //the line of
inserting data finally
const char *sqlite3_errmsg(sqlite3*); //get the
corresponding introduction of error code. These error
messages will be returned in UTF-8, and will be removed
when it calls any SQLite API function next time.
int sqlite3_errcode(sqlite3*); // acquire the error code that
calls the recent API interface.
2) Different implementation ways of SQLite3
• Implement one or more lines of SQL statements and
implement the callback function on the each line of
querying results: int sqlite3_exec();
• Structure the SQL statement dynamically:
char *sqlite3_mprintf(const char*,...);
char *sqlite3_vmprintf(const char*, va_list);
//structure statements,executed by sqlite3_exec
int sqlite3_exec_printf();
//structure querying statements and execute void
sqlite3_free(char *z);// release the memory allocated
by sqlite3_ (v)
• Pre-compile SQL statement, reduce the time of SQL
analysis:
int sqlite3_prepare();// pre-compile
int sqlite3_step(sqlite3_stmt*); //execute once or
more
int sqlite3_reset ( sqlite3_ stmt*);
//reset sqlite3_stmt(come from sqlite3_prepare())
int sqlite3_finalize(sqlite3_stmt *pstmt); //release
• Make use of the encapsulation about sqlite3_exec ()
and return all results:
int sqlite3_get_table();
void sqlite3_free_table(char **result);
C. API function of SQLiteEmbedded database SQLite provides API interface of Clanguage, making operation of the database is very simple.Some of the functions will be introduced briefly in thefollowing paper[4]:1) C/C++ common interface of SQLite3typedef struct sqlite3 sqlite3;int sqlite3_open(const char*, sqlite3**); //open thedatabase, including documents and memory database.int sqlite3_close(sqlite3*); //close the databaseint qlite3_last_insert_rowid(sqlite3*); //the line ofinserting data finallyconst char *sqlite3_errmsg(sqlite3*); //get thecorresponding introduction of error code. These errormessages will be returned in UTF-8, and will be removedwhen it calls any SQLite API function next time.int sqlite3_errcode(sqlite3*); // acquire the error code thatcalls the recent API interface.2) Different implementation ways of SQLite3• Implement one or more lines of SQL statements andimplement the callback function on the each line ofquerying results: int sqlite3_exec();• Structure the SQL statement dynamically:char *sqlite3_mprintf(const char*,...);char *sqlite3_vmprintf(const char*, va_list);//structure statements,executed by sqlite3_execint sqlite3_exec_printf();//structure querying statements and execute voidsqlite3_free(char *z);// release the memory allocatedby sqlite3_ (v)• Pre-compile SQL statement, reduce the time of SQLanalysis:int sqlite3_prepare();// pre-compileint sqlite3_step(sqlite3_stmt*); //execute once ormoreint sqlite3_reset ( sqlite3_ stmt*);//reset sqlite3_stmt(come from sqlite3_prepare())int sqlite3_finalize(sqlite3_stmt *pstmt); //release• Make use of the encapsulation about sqlite3_exec ()and return all results:int sqlite3_get_table();void sqlite3_free_table(char **result);
การแปล กรุณารอสักครู่..