1
/* util.c - various utility functions
3
* Copyright (C) 2005-2007 Gerhard H�ring <gh@ghaering.de>
5
* This file is part of pysqlite.
7
* This software is provided 'as-is', without any express or implied
8
* warranty. In no event will the authors be held liable for any damages
9
* arising from the use of this software.
11
* Permission is granted to anyone to use this software for any purpose,
12
* including commercial applications, and to alter it and redistribute it
13
* freely, subject to the following restrictions:
15
* 1. The origin of this software must not be misrepresented; you must not
16
* claim that you wrote the original software. If you use this software
17
* in a product, an acknowledgment in the product documentation would be
18
* appreciated but is not required.
19
* 2. Altered source versions must be plainly marked as such, and must not be
20
* misrepresented as being the original software.
21
* 3. This notice may not be removed or altered from any source distribution.
25
#include "connection.h"
27
int pysqlite_step(sqlite3_stmt* statement, pysqlite_Connection* connection)
31
if (statement == NULL) {
32
/* this is a workaround for SQLite 3.5 and later. it now apparently
33
* returns NULL for "no-operation" statements */
36
Py_BEGIN_ALLOW_THREADS
37
rc = sqlite3_step(statement);
45
* Checks the SQLite error code and sets the appropriate DB-API exception.
46
* Returns the error code (0 means no error occurred).
48
int _pysqlite_seterror(sqlite3* db, sqlite3_stmt* st)
52
/* SQLite often doesn't report anything useful, unless you reset the statement first */
54
(void)sqlite3_reset(st);
57
errorcode = sqlite3_errcode(db);
66
PyErr_SetString(pysqlite_InternalError, sqlite3_errmsg(db));
69
(void)PyErr_NoMemory();
77
case SQLITE_INTERRUPT:
84
PyErr_SetString(pysqlite_OperationalError, sqlite3_errmsg(db));
87
PyErr_SetString(pysqlite_DatabaseError, sqlite3_errmsg(db));
90
PyErr_SetString(pysqlite_DataError, sqlite3_errmsg(db));
92
case SQLITE_CONSTRAINT:
94
PyErr_SetString(pysqlite_IntegrityError, sqlite3_errmsg(db));
97
PyErr_SetString(pysqlite_ProgrammingError, sqlite3_errmsg(db));
100
PyErr_SetString(pysqlite_DatabaseError, sqlite3_errmsg(db));