[Reprint] learning notes for SQLite common functions

Source: Internet
Author: User
More questions welcome to my forum and exchange http://tcwin.yuxa.com/vbs/

1. Open the database:
Note: open a database. If it does not exist, it is automatically created. The first parameter specifies the file name, and the second parameter is the sqlite3 ** ppdb struct pointer you have defined. It is not necessary to know what the struct is, we only need to know that it is equivalent to a database handle.
Int sqlite3_open (
Const char * filename,/* Database Name (UTF-8 )*/

Sqlite3 ** ppdb/* Out: SQLite database handle */
);

2. Shut down the database:
Description: The parameter is the OODB handle obtained by sqlite3_open. You can call this function to close the database.
Int sqlite3_close (sqlite3 *); // The parameter is the structure just obtained, that is, the database handle.

3. Execute SQL:
Note: This function is used to execute one or more SQL statements separated by the ";" sign. We recommend that you specify the third parameter callback function when executing one or more SQL statements. In the callback function, you can obtain detailed procedures for executing SQL statements, if all SQL statements are executed, 0 is returned. Otherwise, the execution is not completely successful.
Fifth parameter: if the execution fails (no 0 is returned), you can view the fifth elaborated value. To view detailed error information.
Int sqlite3_exec (
Sqlite3 *,/* opened database handle */
Const char * SQL,/* SQL statement to be executed */
Sqlite_callback,/* callback function */
Void *,/* parameters passed to the callback function */
Char ** errmsg/* save error message */
);

4. Take the current insert position:
Function: return the last time you inserted the data. Starting from 1, sqlite3 * opens the database for you to get the handle.
Long long int sqlite3_last_insert_rowid (sqlite3 *);

5. Execute an SQL query:
Function: execute a query SQL statement and return a record set.
Int sqlite3_get_table (
Sqlite3 *,/* opened database handle */
Const char * SQL,/* SQL statement to be executed */
Char *** resultp,/* Save the pointer to the returned record set */
Int * nrow,/* Number of returned records */
Int * ncolumn,/* Number of returned fields */
Char ** errmsg/* error message returned */
)

6. Release query results:
Function: releases the memory occupied by the currently queried record set.
Void sqlite3_free_table (char ** result );

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.