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

📄 capi3ref.tcl.old

📁 sqlite-3.4.1,嵌入式数据库.是一个功能强大的开源数据库,给学习和研发以及小型公司的发展带来了全所未有的好处.
💻 OLD
📖 第 1 页 / 共 5 页
字号:
} {}api {} {char *sqlite3_snprintf(int bufSize, char *buf, const char *zFormat, ...);} {  This routine works like "sprintf()", writing a formatted string into  the buf[].  However, no more than bufSize characters will be written  into buf[].  This routine returns a pointer to buf[].  If bufSize is  greater than zero, then buf[] is guaranteed to be zero-terminated.  This routine uses the same extended formatting options as  sqlite3_mprintf() and sqlite3_vmprintf().  Note these differences with the snprintf() function found in many  standard libraries:  (1)  sqlite3_snprintf() returns a pointer to the  buffer rather than the number of characters written.  (It would,  arguably, be more useful to return the number of characters written,  but we discovered that after the interface had been published and  are unwilling to break backwards compatibility.)  (2)  The order  of the bufSize and buf parameter is reversed from snprintf().    And (3) sqlite3_snprintf() always writes a zero-terminator if bufSize  is positive.    Please do not use the return value of this routine.  We may  decide to make the minor compatibility break and change this routine  to return the number of characters written rather than a pointer to  the buffer in a future minor version increment.}api {} {int sqlite3_open(  const char *filename,   /* Database filename (UTF-8) */  sqlite3 **ppDb          /* OUT: SQLite db handle */);int sqlite3_open16(  const void *filename,   /* Database filename (UTF-16) */  sqlite3 **ppDb          /* OUT: SQLite db handle */);} { Open the sqlite database file "filename".  The "filename" is UTF-8 encoded for sqlite3_open() and UTF-16 encoded in the native byte order for sqlite3_open16().  An sqlite3* handle is returned in *ppDb, even if an error occurs. If the database is opened (or created) successfully, then SQLITE_OK is returned. Otherwise an error code is returned. The sqlite3_errmsg() or sqlite3_errmsg16()  routines can be used to obtain an English language description of the error. If the database file does not exist, then a new database will be created as needed. The encoding for the database will be UTF-8 if sqlite3_open() is called and UTF-16 if sqlite3_open16 is used. Whether or not an error occurs when it is opened, resources associated with the sqlite3* handle should be released by passing it to sqlite3_close() when it is no longer required. The returned sqlite3* can only be used in the same thread in which it was created.  It is an error to call sqlite3_open() in one thread then pass the resulting database handle off to another thread to use.  This restriction is due to goofy design decisions (bugs?) in the way some threading implementations interact with file locks. Note to windows users:  The encoding used for the filename argument of sqlite3_open() must be UTF-8, not whatever codepage is currently defined.  Filenames containing international characters must be converted to UTF-8 prior to passing them into sqlite3_open().}api {} {int sqlite3_prepare_v2(  sqlite3 *db,            /* Database handle */  const char *zSql,       /* SQL statement, UTF-8 encoded */  int nBytes,             /* Length of zSql in bytes. */  sqlite3_stmt **ppStmt,  /* OUT: Statement handle */  const char **pzTail     /* OUT: Pointer to unused portion of zSql */);int sqlite3_prepare16_v2(  sqlite3 *db,            /* Database handle */  const void *zSql,       /* SQL statement, UTF-16 encoded */  int nBytes,             /* Length of zSql in bytes. */  sqlite3_stmt **ppStmt,  /* OUT: Statement handle */  const void **pzTail     /* OUT: Pointer to unused portion of zSql */);/* Legacy Interfaces */int sqlite3_prepare(  sqlite3 *db,            /* Database handle */  const char *zSql,       /* SQL statement, UTF-8 encoded */  int nBytes,             /* Length of zSql in bytes. */  sqlite3_stmt **ppStmt,  /* OUT: Statement handle */  const char **pzTail     /* OUT: Pointer to unused portion of zSql */);int sqlite3_prepare16(  sqlite3 *db,            /* Database handle */  const void *zSql,       /* SQL statement, UTF-16 encoded */  int nBytes,             /* Length of zSql in bytes. */  sqlite3_stmt **ppStmt,  /* OUT: Statement handle */  const void **pzTail     /* OUT: Pointer to unused portion of zSql */);} { To execute an SQL query, it must first be compiled into a byte-code program using one of these routines.  The first argument "db" is an SQLite database handle. The second argument "zSql" is the statement to be compiled, encoded as either UTF-8 or UTF-16.  The sqlite3_prepare_v2() interfaces uses UTF-8 and sqlite3_prepare16_v2() use UTF-16. If the next argument, "nBytes", is less than zero, then zSql is read up to the first nul terminator.  If "nBytes" is not less than zero, then it is the length of the string zSql in bytes (not characters). *pzTail is made to point to the first byte past the end of the first SQL statement in zSql.  This routine only compiles the first statement in zSql, so *pzTail is left pointing to what remains uncompiled. *ppStmt is left pointing to a compiled SQL statement that can be executed using sqlite3_step().  Or if there is an error, *ppStmt may be set to NULL.  If the input text contained no SQL (if the input is and empty string or a comment) then *ppStmt is set to NULL.  The calling procedure is responsible for deleting this compiled SQL statement using sqlite3_finalize() after it has finished with it. On success, SQLITE_OK is returned.  Otherwise an error code is returned. The sqlite3_prepare_v2() and sqlite3_prepare16_v2() interfaces are recommended for all new programs. The two older interfaces are retained for backwards compatibility, but their use is discouraged. In the "v2" interfaces, the prepared statement that is returned (the sqlite3_stmt object) contains a copy of the original SQL. This causes the sqlite3_step() interface to behave a differently in two ways: <ol> <li> If the database schema changes, instead of returning SQLITE_SCHEMA as it always used to do, sqlite3_step() will automatically recompile the SQL statement and try to run it again.  If the schema has changed in a way that makes the statement no longer valid, sqlite3_step() will still return SQLITE_SCHEMA.  But unlike the legacy behavior, SQLITE_SCHEMA is now a fatal error.  Calling sqlite3_prepare_v2() again will not make the error go away.  Note: use sqlite3_errmsg() to find the text of the parsing error that results in an SQLITE_SCHEMA return. </li> <li> When an error occurs,  sqlite3_step() will return one of the detailed result-codes like SQLITE_IOERR or SQLITE_FULL or SQLITE_SCHEMA directly. The legacy behavior was that sqlite3_step() would only return a generic SQLITE_ERROR code and you would have to make a second call to sqlite3_reset() in order to find the underlying cause of the problem. With the "v2" prepare interfaces, the underlying reason for the error is returned directly. </li> </ol>}api {} {void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);} { This routine configures a callback function - the progress callback - that is invoked periodically during long running calls to sqlite3_exec(), sqlite3_step() and sqlite3_get_table(). An example use for this API is to keep a GUI updated during a large query. The progress callback is invoked once for every N virtual machine opcodes, where N is the second argument to this function. The progress callback itself is identified by the third argument to this function. The fourth argument to this function is a void pointer passed to the progress callback function each time it is invoked. If a call to sqlite3_exec(), sqlite3_step() or sqlite3_get_table() results  in less than N opcodes being executed, then the progress callback is not invoked.  To remove the progress callback altogether, pass NULL as the third argument to this function. If the progress callback returns a result other than 0, then the current  query is immediately terminated and any database changes rolled back.  The sqlite3_exec(), sqlite3_step(), or sqlite3_get_table() call returns SQLITE_INTERRUPT. }api {} {int sqlite3_reset(sqlite3_stmt *pStmt);} { The sqlite3_reset() function is called to reset a prepared SQL statement obtained by a previous call to  sqlite3_prepare_v2() or sqlite3_prepare16_v2() back to it's initial state, ready to be re-executed. Any SQL statement variables that had values bound to them using the sqlite3_bind_*() API retain their values.}api {} {void sqlite3_result_blob(sqlite3_context*, const void*, int n, void(*)(void*));void sqlite3_result_double(sqlite3_context*, double);void sqlite3_result_error(sqlite3_context*, const char*, int);void sqlite3_result_error16(sqlite3_context*, const void*, int);void sqlite3_result_int(sqlite3_context*, int);void sqlite3_result_int64(sqlite3_context*, long long int);void sqlite3_result_null(sqlite3_context*);void sqlite3_result_text(sqlite3_context*, const char*, int n, void(*)(void*));void sqlite3_result_text16(sqlite3_context*, const void*, int n, void(*)(void*));void sqlite3_result_text16be(sqlite3_context*, const void*, int n, void(*)(void*));void sqlite3_result_text16le(sqlite3_context*, const void*, int n, void(*)(void*));void sqlite3_result_value(sqlite3_context*, sqlite3_value*);} { User-defined functions invoke these routines in order to set their return value.  The sqlite3_result_value() routine is used to return an exact copy of one of the arguments to the function. The operation of these routines is very similar to the operation of sqlite3_bind_blob() and its cousins.  Refer to the documentation there for additional information.}api {} {int sqlite3_set_authorizer(  sqlite3*,  int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),  void *pUserData);#define SQLITE_CREATE_INDEX          1   /* Index Name      Table Name      */#define SQLITE_CREATE_TABLE          2   /* Table Name      NULL            */#define SQLITE_CREATE_TEMP_INDEX     3   /* Index Name      Table Name      */#define SQLITE_CREATE_TEMP_TABLE     4   /* Table Name      NULL            */#define SQLITE_CREATE_TEMP_TRIGGER   5   /* Trigger Name    Table Name      */#define SQLITE_CREATE_TEMP_VIEW      6   /* View Name       NULL            */#define SQLITE_CREATE_TRIGGER        7   /* Trigger Name    Table Name      */#define SQLITE_CREATE_VIEW           8   /* View Name       NULL            */#define SQLITE_DELETE                9   /* Table Name      NULL            */#define SQLITE_DROP_INDEX           10   /* Index Name      Table Name      */#define SQLITE_DROP_TABLE           11   /* Table Name      NULL            */#define SQLITE_DROP_TEMP_INDEX      12   /* Index Name      Table Name      */#define SQLITE_DROP_TEMP_TABLE      13   /* Table Name      NULL            */#define SQLITE_DROP_TEMP_TRIGGER    14   /* Trigger Name    Table Name      */#define SQLITE_DROP_TEMP_VIEW       15   /* View Name       NULL            */#define SQLITE_DROP_TRIGGER         16   /* Trigger Name    Table Name      */#define SQLITE_DROP_VIEW            17   /* View Name       NULL            */#define SQLITE_INSERT               18   /* Table Name      NULL            */#define SQLITE_PRAGMA               19   /* Pragma Name     1st arg or NULL */#define SQLITE_READ                 20   /* Table Name      Column Name     */#define SQLITE_SELECT               21   /* NULL            NULL            */#define SQLITE_TRANSACTION          22   /* NULL            NULL            */#define SQLITE_UPDATE               23   /* Table Name      Column Name     */#define SQLITE_ATTACH               24   /* Filename        NULL            */#define SQLITE_DETACH               25   /* Database Name   NULL            */#define SQLITE_ALTER_TABLE          26   /* Database Name   Table Name      */#define SQLITE_REINDEX              27   /* Index Name      NULL            */#define SQLITE_ANALYZE              28   /* Table Name      NULL            */#define SQLITE_CREATE_VTABLE        29   /* Table Name      Module Name     */#define SQLITE_DROP_VTABLE          30   /* Table Name      Module Name     */#define SQLITE_FUNCTION             31   /* Function Name   NULL            */#define SQLITE_DENY   1   /* Abort the SQL statement with an error */#define SQLITE_IGNORE 2   /* Don't allow access, but don't generate an error */} { This routine registers a callback with the SQLite library.  The callback is invoked by sqlite3_prepare_v2() to authorize various operations against the database.  The callback should return SQLITE_OK if access is allowed, SQLITE_DENY if the entire SQL statement should be aborted with an error and SQLITE_IGNORE if the operation should be treated as a no-op. Each database connection have at most one authorizer registered at a time one time.  Each call to sqlite3_set_authorizer() overrides the previous authorizer. Setting the callback to NULL disables the authorizer. The second argument to the access authorization function will be one of the defined constants shown.  These values signify what kind of operation is to be authorized.  The 3rd and 4th arguments to the authorization function will be arguments or NULL depending on which of the  codes is used as the second argument.  For example, if the the 2nd argument code is SQLITE_READ then the 3rd argument will be the name of the table that is being read from and the 4th argument will be the name of the column that is being read from.  Or if the 2nd argument is SQLITE_FUNCTION then the 3rd argument will be the name of the function that is being invoked and the 4th argument will be NULL. The 5th argument is the name of the database ("main", "temp", etc.) where applicable.  The 6th argument is the name of the inner-most trigger or view that is responsible for the access attempt or NULL if this access attempt is directly from  input SQL code. The return value of the authorization callback function should be one of the constants SQLITE_OK, SQLITE_DENY, or SQLITE_IGNORE.  A return of SQLITE_OK means that the operation is permitted and that  sqlite3

⌨️ 快捷键说明

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