Learning database SQLite Programming

Source: Internet
Author: User

Using the C library function interface of SQLite to access database files is similar to reading and writing files that have previously been learned. open the file with sqlite3_open and close the file with sqlite3_close, use a sqlite3 * pointer to indicate an opened database file. All queries and operations on the database are completed by passing this pointer to call the corresponding function interface. Sqlite3_exec executes SQL query on an opened database file

Typedef int (* sqlite_callback) (void * parg, int argc, char ** argv, char ** argvv );

Int sqlite3_exec (sqlite3 * dB, const char * zsql, sqlite_callback xcallback, void parg, char ** pzerrmsg );

If the zsql parameter is a SELECT query, a callback function is called for each row of the query results. The parg parameter can be used to pass a parameter to the callback function. If an error occurs, pzerrmsg points to the error message string. In the callback function, you can read the total number of columns in this row through argc, read data in each column through argv, and read the column name through argvv. If zsql is not a SELECT query, the callback function is not called.

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.