/* connection.h - definitions for the connection type1*2* Copyright (C) 2004-2010 Gerhard Häring <[email protected]>3*4* This file is part of pysqlite.5*6* This software is provided 'as-is', without any express or implied7* warranty. In no event will the authors be held liable for any damages8* arising from the use of this software.9*10* Permission is granted to anyone to use this software for any purpose,11* including commercial applications, and to alter it and redistribute it12* freely, subject to the following restrictions:13*14* 1. The origin of this software must not be misrepresented; you must not15* claim that you wrote the original software. If you use this software16* in a product, an acknowledgment in the product documentation would be17* appreciated but is not required.18* 2. Altered source versions must be plainly marked as such, and must not be19* misrepresented as being the original software.20* 3. This notice may not be removed or altered from any source distribution.21*/2223#ifndef PYSQLITE_CONNECTION_H24#define PYSQLITE_CONNECTION_H25#include "Python.h"26#include "pythread.h"27#include "structmember.h"2829#include "module.h"3031#include "sqlite3.h"3233typedef struct _callback_context34{35PyObject *callable;36PyObject *module;37pysqlite_state *state;38} callback_context;3940enum autocommit_mode {41AUTOCOMMIT_LEGACY = LEGACY_TRANSACTION_CONTROL,42AUTOCOMMIT_ENABLED = 1,43AUTOCOMMIT_DISABLED = 0,44};4546typedef struct47{48PyObject_HEAD49sqlite3 *db;50pysqlite_state *state;5152/* the type detection mode. Only 0, PARSE_DECLTYPES, PARSE_COLNAMES or a53* bitwise combination thereof makes sense */54int detect_types;5556/* NULL for autocommit, otherwise a string with the isolation level */57const char *isolation_level;58enum autocommit_mode autocommit;5960/* 1 if a check should be performed for each API call if the connection is61* used from the same thread it was created in */62int check_same_thread;6364int initialized;6566/* thread identification of the thread the connection was created in */67unsigned long thread_ident;6869PyObject *statement_cache;7071/* Lists of weak references to cursors and blobs used within this connection */72PyObject *cursors;73PyObject *blobs;7475/* Counters for how many cursors were created in the connection. May be76* reset to 0 at certain intervals */77int created_cursors;7879PyObject* row_factory;8081/* Determines how bytestrings from SQLite are converted to Python objects:82* - PyUnicode_Type: Python Unicode objects are constructed from UTF-8 bytestrings83* - PyBytes_Type: The bytestrings are returned as-is.84* - Any custom callable: Any object returned from the callable called with the bytestring85* as single parameter.86*/87PyObject* text_factory;8889// Remember contexts used by the trace, progress, and authoriser callbacks90callback_context *trace_ctx;91callback_context *progress_ctx;92callback_context *authorizer_ctx;9394/* Exception objects: borrowed refs. */95PyObject* Warning;96PyObject* Error;97PyObject* InterfaceError;98PyObject* DatabaseError;99PyObject* DataError;100PyObject* OperationalError;101PyObject* IntegrityError;102PyObject* InternalError;103PyObject* ProgrammingError;104PyObject* NotSupportedError;105} pysqlite_Connection;106107int pysqlite_check_thread(pysqlite_Connection* self);108int pysqlite_check_connection(pysqlite_Connection* con);109110int pysqlite_connection_setup_types(PyObject *module);111112#endif113114115