Back to index

python3.2  3.2.2
Functions
util.h File Reference
#include "Python.h"
#include "pythread.h"
#include "sqlite3.h"
#include "connection.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int pysqlite_step (sqlite3_stmt *statement, pysqlite_Connection *connection)
int _pysqlite_seterror (sqlite3 *db, sqlite3_stmt *st)
 Checks the SQLite error code and sets the appropriate DB-API exception.

Function Documentation

int _pysqlite_seterror ( sqlite3 *  db,
sqlite3_stmt *  st 
)

Checks the SQLite error code and sets the appropriate DB-API exception.

Returns the error code (0 means no error occurred).

Definition at line 48 of file util.c.

{
    int errorcode;

    /* SQLite often doesn't report anything useful, unless you reset the statement first */
    if (st != NULL) {
        (void)sqlite3_reset(st);
    }

    errorcode = sqlite3_errcode(db);

    switch (errorcode)
    {
        case SQLITE_OK:
            PyErr_Clear();
            break;
        case SQLITE_INTERNAL:
        case SQLITE_NOTFOUND:
            PyErr_SetString(pysqlite_InternalError, sqlite3_errmsg(db));
            break;
        case SQLITE_NOMEM:
            (void)PyErr_NoMemory();
            break;
        case SQLITE_ERROR:
        case SQLITE_PERM:
        case SQLITE_ABORT:
        case SQLITE_BUSY:
        case SQLITE_LOCKED:
        case SQLITE_READONLY:
        case SQLITE_INTERRUPT:
        case SQLITE_IOERR:
        case SQLITE_FULL:
        case SQLITE_CANTOPEN:
        case SQLITE_PROTOCOL:
        case SQLITE_EMPTY:
        case SQLITE_SCHEMA:
            PyErr_SetString(pysqlite_OperationalError, sqlite3_errmsg(db));
            break;
        case SQLITE_CORRUPT:
            PyErr_SetString(pysqlite_DatabaseError, sqlite3_errmsg(db));
            break;
        case SQLITE_TOOBIG:
            PyErr_SetString(pysqlite_DataError, sqlite3_errmsg(db));
            break;
        case SQLITE_CONSTRAINT:
        case SQLITE_MISMATCH:
            PyErr_SetString(pysqlite_IntegrityError, sqlite3_errmsg(db));
            break;
        case SQLITE_MISUSE:
            PyErr_SetString(pysqlite_ProgrammingError, sqlite3_errmsg(db));
            break;
        default:
            PyErr_SetString(pysqlite_DatabaseError, sqlite3_errmsg(db));
            break;
    }

    return errorcode;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int pysqlite_step ( sqlite3_stmt *  statement,
pysqlite_Connection connection 
)

Definition at line 27 of file util.c.

{
    int rc;

    if (statement == NULL) {
        /* this is a workaround for SQLite 3.5 and later. it now apparently
         * returns NULL for "no-operation" statements */
        rc = SQLITE_OK;
    } else {
        Py_BEGIN_ALLOW_THREADS
        rc = sqlite3_step(statement);
        Py_END_ALLOW_THREADS
    }

    return rc;
}

Here is the caller graph for this function: