Back to index

python3.2  3.2.2
Classes | Defines | Enumerations | Functions | Variables
cursor.h File Reference
#include "Python.h"
#include "statement.h"
#include "connection.h"
#include "module.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  pysqlite_Cursor

Defines

#define UNKNOWN   (-1)

Enumerations

enum  pysqlite_StatementKind {
  STATEMENT_INVALID, STATEMENT_INSERT, STATEMENT_DELETE, STATEMENT_UPDATE,
  STATEMENT_REPLACE, STATEMENT_SELECT, STATEMENT_OTHER
}

Functions

PyObjectpysqlite_cursor_execute (pysqlite_Cursor *self, PyObject *args)
PyObjectpysqlite_cursor_executemany (pysqlite_Cursor *self, PyObject *args)
PyObjectpysqlite_cursor_getiter (pysqlite_Cursor *self)
PyObjectpysqlite_cursor_iternext (pysqlite_Cursor *self)
PyObjectpysqlite_cursor_fetchone (pysqlite_Cursor *self, PyObject *args)
PyObjectpysqlite_cursor_fetchmany (pysqlite_Cursor *self, PyObject *args, PyObject *kwargs)
PyObjectpysqlite_cursor_fetchall (pysqlite_Cursor *self, PyObject *args)
PyObjectpysqlite_noop (pysqlite_Connection *self, PyObject *args)
PyObjectpysqlite_cursor_close (pysqlite_Cursor *self, PyObject *args)
int pysqlite_cursor_setup_types (void)

Variables

PyTypeObject pysqlite_CursorType

Class Documentation

struct pysqlite_Cursor

Definition at line 32 of file cursor.h.

Collaboration diagram for pysqlite_Cursor:
Class Members
int arraysize
int closed
PyObject_HEAD pysqlite_Connection * connection
PyObject * description
PyObject * in_weakreflist
int initialized
PyObject * lastrowid
PyObject * next_row
int reset
PyObject * row_cast_map
PyObject * row_factory
long rowcount
pysqlite_Statement * statement

Define Documentation

#define UNKNOWN   (-1)

Definition at line 73 of file cursor.h.


Enumeration Type Documentation

Enumerator:
STATEMENT_INVALID 
STATEMENT_INSERT 
STATEMENT_DELETE 
STATEMENT_UPDATE 
STATEMENT_REPLACE 
STATEMENT_SELECT 
STATEMENT_OTHER 

Definition at line 53 of file cursor.h.


Function Documentation

Definition at line 1007 of file cursor.c.

{
    if (!pysqlite_check_thread(self->connection) || !pysqlite_check_connection(self->connection)) {
        return NULL;
    }

    if (self->statement) {
        (void)pysqlite_statement_reset(self->statement);
        Py_CLEAR(self->statement);
    }

    self->closed = 1;

    Py_INCREF(Py_None);
    return Py_None;
}

Here is the call graph for this function:

Definition at line 764 of file cursor.c.

{
    return _pysqlite_query_execute(self, 0, args);
}

Here is the call graph for this function:

Definition at line 769 of file cursor.c.

{
    return _pysqlite_query_execute(self, 1, args);
}

Here is the call graph for this function:

Definition at line 971 of file cursor.c.

{
    PyObject* row;
    PyObject* list;

    list = PyList_New(0);
    if (!list) {
        return NULL;
    }

    /* just make sure we enter the loop */
    row = (PyObject*)Py_None;

    while (row) {
        row = pysqlite_cursor_iternext(self);
        if (row) {
            PyList_Append(list, row);
            Py_DECREF(row);
        }
    }

    if (PyErr_Occurred()) {
        Py_DECREF(list);
        return NULL;
    } else {
        return list;
    }
}

Here is the call graph for this function:

PyObject* pysqlite_cursor_fetchmany ( pysqlite_Cursor self,
PyObject args,
PyObject kwargs 
)

Definition at line 928 of file cursor.c.

{
    static char *kwlist[] = {"size", NULL, NULL};

    PyObject* row;
    PyObject* list;
    int maxrows = self->arraysize;
    int counter = 0;

    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|i:fetchmany", kwlist, &maxrows)) {
        return NULL;
    }

    list = PyList_New(0);
    if (!list) {
        return NULL;
    }

    /* just make sure we enter the loop */
    row = Py_None;

    while (row) {
        row = pysqlite_cursor_iternext(self);
        if (row) {
            PyList_Append(list, row);
            Py_DECREF(row);
        } else {
            break;
        }

        if (++counter == maxrows) {
            break;
        }
    }

    if (PyErr_Occurred()) {
        Py_DECREF(list);
        return NULL;
    } else {
        return list;
    }
}

Here is the call graph for this function:

Definition at line 915 of file cursor.c.

{
    PyObject* row;

    row = pysqlite_cursor_iternext(self);
    if (!row && !PyErr_Occurred()) {
        Py_INCREF(Py_None);
        return Py_None;
    }

    return row;
}

Here is the call graph for this function:

Definition at line 858 of file cursor.c.

{
    Py_INCREF(self);
    return (PyObject*)self;
}

Definition at line 864 of file cursor.c.

{
    PyObject* next_row_tuple;
    PyObject* next_row;
    int rc;

    if (!check_cursor(self)) {
        return NULL;
    }

    if (self->reset) {
        PyErr_SetString(pysqlite_InterfaceError, errmsg_fetch_across_rollback);
        return NULL;
    }

    if (!self->next_row) {
         if (self->statement) {
            (void)pysqlite_statement_reset(self->statement);
            Py_DECREF(self->statement);
            self->statement = NULL;
        }
        return NULL;
    }

    next_row_tuple = self->next_row;
    self->next_row = NULL;

    if (self->row_factory != Py_None) {
        next_row = PyObject_CallFunction(self->row_factory, "OO", self, next_row_tuple);
        Py_DECREF(next_row_tuple);
    } else {
        next_row = next_row_tuple;
    }

    if (self->statement) {
        rc = pysqlite_step(self->statement->st, self->connection);
        if (rc != SQLITE_DONE && rc != SQLITE_ROW) {
            (void)pysqlite_statement_reset(self->statement);
            Py_DECREF(next_row);
            _pysqlite_seterror(self->connection->db, NULL);
            return NULL;
        }

        if (rc == SQLITE_ROW) {
            self->next_row = _pysqlite_fetch_one_row(self);
        }
    }

    return next_row;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1102 of file cursor.c.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1000 of file cursor.c.

{
    /* don't care, return None */
    Py_INCREF(Py_None);
    return Py_None;
}

Variable Documentation

Definition at line 1060 of file cursor.c.