Small. Fast. Reliable.
Choose any three.

About Sitemap Documentation Download License News Developers Support

## SQLite C Interface

## Closing A Database Connection

>     int sqlite3_close(sqlite3 *);

This routine is the destructor for the sqlite3 object.

Applications should finalize all prepared statements and close all BLOB handles associated with the sqlite3 object prior to attempting to close the object. The sqlite3_next_stmt() interface can be used to locate all prepared statements associated with a database connection if desired. Typical code might look like this:

>     sqlite3_stmt *pStmt;
>     while( (pStmt = sqlite3_next_stmt(db, 0))!=0 ){
>         sqlite3_finalize(pStmt);
>     }

If sqlite3_close() is invoked while a transaction is open, the transaction is automatically rolled back.

### Invariants:

H12011 | A successful call to sqlite3_close(C) shall destroy the database connection object C.
H12012 | A successful call to sqlite3_close(C) shall return SQLITE_OK.
H12013 | A successful call to sqlite3_close(C) shall release all memory and system resources associated with database connection C.
H12014 | A call to sqlite3_close(C) on a database connection C that has one or more open prepared statements shall fail with an SQLITE_BUSY error code.
H12015 | A call to sqlite3_close(C) where C is a NULL pointer shall be a harmless no-op returning SQLITE_OK.
H12019 | When sqlite3_close(C) is invoked on a database connection C that has a pending transaction, the transaction shall be rolled back.

### Assumptions:

A12016 | The C parameter to sqlite3_close(C) must be either a NULL pointer or an sqlite3 object pointer obtained from sqlite3_open(), sqlite3_open16(), or sqlite3_open_v2(), and not previously closed.

See also lists of Objects, Constants, and Functions.

This page last modified 2008/08/11 17:57:43 UTC