⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cintro.html

📁 sqlite3源码,适合作为嵌入式(embedded)
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html><head><title>An Introduction To The SQLite C/C++ Interface</title><style type="text/css">body {    margin: auto;    font-family: "Verdana" "sans-serif";    padding: 8px 1%;}a { color: #45735f }a:visited { color: #734559 }.logo { position:absolute; margin:3px; }.tagline {  float:right;  text-align:right;  font-style:italic;  width:240px;  margin:12px;  margin-top:58px;}.toolbar {  font-variant: small-caps;  text-align: center;  line-height: 1.6em;  margin: 0;  padding:1px 8px;}.toolbar a { color: white; text-decoration: none; padding: 6px 12px; }.toolbar a:visited { color: white; }.toolbar a:hover { color: #80a796; background: white; }.content    { margin: 5%; }.content dt { font-weight:bold; }.content dd { margin-bottom: 25px; margin-left:20%; }.content ul { padding:0px; padding-left: 15px; margin:0px; }/* rounded corners */.se  { background: url(images/se.png) 100% 100% no-repeat #80a796}.sw  { background: url(images/sw.png) 0% 100% no-repeat }.ne  { background: url(images/ne.png) 100% 0% no-repeat }.nw  { background: url(images/nw.png) 0% 0% no-repeat }</style><meta http-equiv="content-type" content="text/html; charset=UTF-8">  </head><body><div><!-- container div to satisfy validator --><a href="index.html"><img class="logo" src="images/SQLite.gif" alt="SQLite Logo" border="0"></a><div><!-- IE hack to prevent disappearing logo--></div><div class="tagline">Small. Fast. Reliable.<br>Choose any three.</div><table width=100% style="clear:both"><tr><td>  <div class="se"><div class="sw"><div class="ne"><div class="nw">  <div class="toolbar">    <a href="about.html">About</a>    <a href="sitemap.html">Sitemap</a>    <a href="docs.html">Documentation</a>    <a href="download.html">Download</a>    <a href="copyright.html">License</a>    <a href="news.html">News</a>    <a href="http://www.sqlite.org/cvstrac/index">Developers</a>    <a href="support.html">Support</a>  </div></div></div></div></div></td></tr></table>  <h1> An Introduction To The SQLite C/C++ Interface</h1><p>  This article provides an overview and roadmap to the C/C++ interface  to SQLite.</p><p>  Early versions of SQLite were very easy to learn since they only  supported 5 C/C++ interfaces.  But as SQLite has grown in capability  new C/C++ interfaces have been added so that now there  are over 150 distinct APIs.  This can be overwhelming to a new programmer.  Fortunately, most of the C/C++ interfaces in SQLite are very specialized  and never need to be used.  Despite having so many  entry points, the core API is still relatively simple and easy to code to.  This article aims to provide all of the background information needed to  easily understand how SQLite works.</p><p>  A separate document, <a href="c3ref/intro.html">The SQLite C/C++ Interface</a>,  provides detailed  specifications for all of the various C/C++ APIs for SQLite.  Once  the reader  understands the basic principles of operation for SQLite,   <a href="c3ref/intro.html">that document</a> should be used as a reference  guide.  This article is intended as introduction only and is neither a  complete or authoritative reference for the SQLite API.</p><h2>1.0 Core Objects And Interfaces</h2><p>  The principal function of an SQL database engine is to evaluate statements  of SQL.  In order to accomplish this purpose, the developer needs  to know about two objects:</p><p><ul>  <li> The <a href="c3ref/sqlite3.html">database connection</a> object: sqlite3 </li>  <li> The <a href="c3ref/stmt.html">prepared statement</a> object: sqlite3_stmt </li></ul></p><p>  Strictly speaking, the <a href="c3ref/stmt.html">prepared statement</a> object is not required since  the convenience wrapper interfaces, <a href="c3ref/exec.html">sqlite3_exec</a> or  <a href="c3ref/free_table.html">sqlite3_get_table</a>, that encapsulate and hide the <a href="c3ref/stmt.html">prepared statement</a>  can be used instead.  Nevertheless, and understanding of  <a href="c3ref/stmt.html">prepared statements</a> is needed to make full use of SQLite.</p><p>  The <a href="c3ref/sqlite3.html">database connection</a> and <a href="c3ref/stmt.html">prepared statement</a> objects are controlled  by a small set of C/C++ interface routine listed below.</p><p><ul>  <li> <a href="c3ref/open.html">sqlite3_open()</a> </li>  <li> <a href="c3ref/prepare.html">sqlite3_prepare()</a> </li>  <li> <a href="c3ref/step.html">sqlite3_step()</a> </li>  <li> <a href="c3ref/column_blob.html">sqlite3_column()</a> </li>  <li> <a href="c3ref/finalize.html">sqlite3_finalize()</a> </li>  <li> <a href="c3ref/close.html">sqlite3_close()</a> </li></ul></p><p>  The six C/C++ interface routines and two objects listed above form the core  functionality of SQLite.  The developer who understands them  will have a good foundation for using SQLite.</p><p>  Note that the list of routines is conceptual rather than actual.  Many of these routines come in multiple versions.  For example, the list above shows a single routine  named <a href="c3ref/open.html">sqlite3_open()</a> when in fact there are three separate routines  that accomplish the same thing in slightly different ways:  <a href="c3ref/open.html">sqlite3_open()</a>, <a href="c3ref/open.html">sqlite3_open16()</a> and <a href="c3ref/open.html">sqlite3_open_v2()</a>.  The list mentions <a href="c3ref/column_blob.html">sqlite3_column()</a>  when in fact no such routine exists.  The "sqlite3_column()" shown in the list is place holders for  an entire families of routines to be used for extracting column  data in various datatypes.</p><p>  Here is a summary of what the core interfaces do:</p><table border="0" cellspacing="15"><tr><td valign="top" align="right"><a href="c3ref/open.html">sqlite3_open()</a></td><td valign="top">  This routine   opens a connection to an SQLite database file and returns a  <a href="c3ref/sqlite3.html">database connection</a> object.  This is often the first SQLite API  call that an application makes and is a prerequisite for most other  SQLite APIs.  Many SQLite interfaces require a pointer to  the <a href="c3ref/sqlite3.html">database connection</a> object as their first parameter and can  be thought of as methods on the <a href="c3ref/sqlite3.html">database connection</a> object.  This routine is the constructor for the <a href="c3ref/sqlite3.html">database connection</a> object.</td><tr><td valign="top" align="right"><a href="c3ref/prepare.html">sqlite3_prepare()</a></td><td valign="top">  This routine  converts SQL text into a <a href="c3ref/stmt.html">prepared statement</a> object and return a pointer  to that object.  This interface requires a <a href="c3ref/sqlite3.html">database connection</a> pointer  created by a prior call to <a href="c3ref/open.html">sqlite3_open()</a> and a text string containing  the SQL statement to be prepared.  This API does not actually evaluate  the SQL statement.  It merely prepares the SQL statement for evaluation.  <p>Note that the use of <a href="c3ref/prepare.html">sqlite3_prepare()</a> is not recommended for new  applications.  The alternative routine <a href="c3ref/prepare.html">sqlite3_prepare_v2()</a> should  be used instead.</p></td><tr><td valign="top" align="right"><a href="c3ref/step.html">sqlite3_step()</a></td><td valign="top">  This routine is used to evaluate a <a href="c3ref/stmt.html">prepared statement</a> that has been  previously created by the <a href="c3ref/prepare.html">sqlite3_prepare()</a> interface.  The statement  is evaluated up to the point where the first row of results are available.  To advance to the second row of results, invoke <a href="c3ref/step.html">sqlite3_step()</a> again.  Continue invoking <a href="c3ref/step.html">sqlite3_step()</a> until the statement is complete.  Statements that do not return results (ex: INSERT, UPDATE, or DELETE  statements) run to completion on a single call to <a href="c3ref/step.html">sqlite3_step()</a>.</td><tr><td valign="top" align="right"><a href="c3ref/column_blob.html">sqlite3_column()</a></td><td valign="top">  This routine returns a single column from the current row of a result  set for a <a href="c3ref/stmt.html">prepared statement</a> that is being evaluated by <a href="c3ref/step.html">sqlite3_step()</a>.  Each time <a href="c3ref/step.html">sqlite3_step()</a> stops with a new result set row, this routine  can be called multiple times to find the values of all columns in that row.  As noted above, there really is no such thing as a "sqlite3_column()"  function in the SQLite API.  Instead, what we here call "sqlite3_column()"  is really a place-holder for an entire family of functions that return  a value from the result set in various data types.  There are also routines  in this family that return the size of the result (if it is a string or  BLOB) and the number of columns in the result set.    <p><ul>    <li> <a href="c3ref/column_blob.html">sqlite3_column_blob()</a> </li>    <li> <a href="c3ref/column_blob.html">sqlite3_column_bytes()</a> </li>    <li> <a href="c3ref/column_blob.html">sqlite3_column_bytes16()</a> </li>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -