Mercurial > cpython-lru_cache-weakref
annotate Modules/_sqlite/module.c @ 39496:352ffe77b71d legacy-trunk
Patch #1535500: fix segfault in BZ2File.writelines and make sure it
raises the correct exceptions.
| author | Georg Brandl <georg@python.org> |
|---|---|
| date | Mon, 14 Aug 2006 21:42:55 +0000 |
| parents | 3e5fd2b70e5a |
| children | 69ea12db9b28 b9d4ced23506 |
| rev | line source |
|---|---|
|
38808
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
1 /* module.c - the module itself |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
2 * |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
3 * Copyright (C) 2004-2006 Gerhard Häring <gh@ghaering.de> |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
4 * |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
5 * This file is part of pysqlite. |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
6 * |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
7 * This software is provided 'as-is', without any express or implied |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
8 * warranty. In no event will the authors be held liable for any damages |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
9 * arising from the use of this software. |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
10 * |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
11 * Permission is granted to anyone to use this software for any purpose, |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
12 * including commercial applications, and to alter it and redistribute it |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
13 * freely, subject to the following restrictions: |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
14 * |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
15 * 1. The origin of this software must not be misrepresented; you must not |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
16 * claim that you wrote the original software. If you use this software |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
17 * in a product, an acknowledgment in the product documentation would be |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
18 * appreciated but is not required. |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
19 * 2. Altered source versions must be plainly marked as such, and must not be |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
20 * misrepresented as being the original software. |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
21 * 3. This notice may not be removed or altered from any source distribution. |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
22 */ |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
23 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
24 #include "connection.h" |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
25 #include "statement.h" |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
26 #include "cursor.h" |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
27 #include "cache.h" |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
28 #include "prepare_protocol.h" |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
29 #include "microprotocols.h" |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
30 #include "row.h" |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
31 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
32 #if SQLITE_VERSION_NUMBER >= 3003003 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
33 #define HAVE_SHARED_CACHE |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
34 #endif |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
35 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
36 /* static objects at module-level */ |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
37 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
38 PyObject* Error, *Warning, *InterfaceError, *DatabaseError, *InternalError, |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
39 *OperationalError, *ProgrammingError, *IntegrityError, *DataError, |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
40 *NotSupportedError, *OptimizedUnicode; |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
41 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
42 PyObject* converters; |
|
38808
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
43 int _enable_callback_tracebacks; |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
44 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
45 static PyObject* module_connect(PyObject* self, PyObject* args, PyObject* |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
46 kwargs) |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
47 { |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
48 /* Python seems to have no way of extracting a single keyword-arg at |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
49 * C-level, so this code is redundant with the one in connection_init in |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
50 * connection.c and must always be copied from there ... */ |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
51 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
52 static char *kwlist[] = {"database", "timeout", "detect_types", "isolation_level", "check_same_thread", "factory", "cached_statements", NULL, NULL}; |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
53 char* database; |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
54 int detect_types = 0; |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
55 PyObject* isolation_level; |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
56 PyObject* factory = NULL; |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
57 int check_same_thread = 1; |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
58 int cached_statements; |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
59 double timeout = 5.0; |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
60 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
61 PyObject* result; |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
62 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
63 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|diOiOi", kwlist, |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
64 &database, &timeout, &detect_types, &isolation_level, &check_same_thread, &factory, &cached_statements)) |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
65 { |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
66 return NULL; |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
67 } |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
68 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
69 if (factory == NULL) { |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
70 factory = (PyObject*)&ConnectionType; |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
71 } |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
72 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
73 result = PyObject_Call(factory, args, kwargs); |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
74 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
75 return result; |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
76 } |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
77 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
78 static PyObject* module_complete(PyObject* self, PyObject* args, PyObject* |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
79 kwargs) |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
80 { |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
81 static char *kwlist[] = {"statement", NULL, NULL}; |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
82 char* statement; |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
83 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
84 PyObject* result; |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
85 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
86 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s", kwlist, &statement)) |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
87 { |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
88 return NULL; |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
89 } |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
90 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
91 if (sqlite3_complete(statement)) { |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
92 result = Py_True; |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
93 } else { |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
94 result = Py_False; |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
95 } |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
96 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
97 Py_INCREF(result); |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
98 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
99 return result; |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
100 } |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
101 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
102 #ifdef HAVE_SHARED_CACHE |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
103 static PyObject* module_enable_shared_cache(PyObject* self, PyObject* args, PyObject* |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
104 kwargs) |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
105 { |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
106 static char *kwlist[] = {"do_enable", NULL, NULL}; |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
107 int do_enable; |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
108 int rc; |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
109 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
110 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i", kwlist, &do_enable)) |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
111 { |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
112 return NULL; |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
113 } |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
114 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
115 rc = sqlite3_enable_shared_cache(do_enable); |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
116 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
117 if (rc != SQLITE_OK) { |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
118 PyErr_SetString(OperationalError, "Changing the shared_cache flag failed"); |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
119 return NULL; |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
120 } else { |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
121 Py_INCREF(Py_None); |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
122 return Py_None; |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
123 } |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
124 } |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
125 #endif /* HAVE_SHARED_CACHE */ |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
126 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
127 static PyObject* module_register_adapter(PyObject* self, PyObject* args, PyObject* kwargs) |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
128 { |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
129 PyTypeObject* type; |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
130 PyObject* caster; |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
131 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
132 if (!PyArg_ParseTuple(args, "OO", &type, &caster)) { |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
133 return NULL; |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
134 } |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
135 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
136 microprotocols_add(type, (PyObject*)&SQLitePrepareProtocolType, caster); |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
137 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
138 Py_INCREF(Py_None); |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
139 return Py_None; |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
140 } |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
141 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
142 static PyObject* module_register_converter(PyObject* self, PyObject* args, PyObject* kwargs) |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
143 { |
|
38808
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
144 char* orig_name; |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
145 char* name = NULL; |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
146 char* c; |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
147 PyObject* callable; |
|
38808
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
148 PyObject* retval = NULL; |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
149 |
|
38808
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
150 if (!PyArg_ParseTuple(args, "sO", &orig_name, &callable)) { |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
151 return NULL; |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
152 } |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
153 |
|
38808
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
154 /* convert the name to lowercase */ |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
155 name = PyMem_Malloc(strlen(orig_name) + 2); |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
156 if (!name) { |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
157 goto error; |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
158 } |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
159 strcpy(name, orig_name); |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
160 for (c = name; *c != (char)0; c++) { |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
161 *c = (*c) & 0xDF; |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
162 } |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
163 |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
164 if (PyDict_SetItemString(converters, name, callable) != 0) { |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
165 goto error; |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
166 } |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
167 |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
168 Py_INCREF(Py_None); |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
169 retval = Py_None; |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
170 error: |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
171 if (name) { |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
172 PyMem_Free(name); |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
173 } |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
174 return retval; |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
175 } |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
176 |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
177 static PyObject* enable_callback_tracebacks(PyObject* self, PyObject* args, PyObject* kwargs) |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
178 { |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
179 if (!PyArg_ParseTuple(args, "i", &_enable_callback_tracebacks)) { |
|
37458
d27058c409df
Update to pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37362
diff
changeset
|
180 return NULL; |
|
d27058c409df
Update to pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37362
diff
changeset
|
181 } |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
182 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
183 Py_INCREF(Py_None); |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
184 return Py_None; |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
185 } |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
186 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
187 void converters_init(PyObject* dict) |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
188 { |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
189 converters = PyDict_New(); |
|
37458
d27058c409df
Update to pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37362
diff
changeset
|
190 if (!converters) { |
|
d27058c409df
Update to pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37362
diff
changeset
|
191 return; |
|
d27058c409df
Update to pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37362
diff
changeset
|
192 } |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
193 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
194 PyDict_SetItemString(dict, "converters", converters); |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
195 } |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
196 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
197 static PyMethodDef module_methods[] = { |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
198 {"connect", (PyCFunction)module_connect, METH_VARARGS|METH_KEYWORDS, PyDoc_STR("Creates a connection.")}, |
|
37938
7da4af95ebad
Updated the sqlite3 module to the external pysqlite 2.2.2 version.
Gerhard Häring <gh@ghaering.de>
parents:
37495
diff
changeset
|
199 {"complete_statement", (PyCFunction)module_complete, METH_VARARGS|METH_KEYWORDS, PyDoc_STR("Checks if a string contains a complete SQL statement. Non-standard.")}, |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
200 #ifdef HAVE_SHARED_CACHE |
|
37938
7da4af95ebad
Updated the sqlite3 module to the external pysqlite 2.2.2 version.
Gerhard Häring <gh@ghaering.de>
parents:
37495
diff
changeset
|
201 {"enable_shared_cache", (PyCFunction)module_enable_shared_cache, METH_VARARGS|METH_KEYWORDS, PyDoc_STR("Enable or disable shared cache mode for the calling thread. Experimental/Non-standard.")}, |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
202 #endif |
|
37938
7da4af95ebad
Updated the sqlite3 module to the external pysqlite 2.2.2 version.
Gerhard Häring <gh@ghaering.de>
parents:
37495
diff
changeset
|
203 {"register_adapter", (PyCFunction)module_register_adapter, METH_VARARGS, PyDoc_STR("Registers an adapter with pysqlite's adapter registry. Non-standard.")}, |
|
7da4af95ebad
Updated the sqlite3 module to the external pysqlite 2.2.2 version.
Gerhard Häring <gh@ghaering.de>
parents:
37495
diff
changeset
|
204 {"register_converter", (PyCFunction)module_register_converter, METH_VARARGS, PyDoc_STR("Registers a converter with pysqlite. Non-standard.")}, |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
205 {"adapt", (PyCFunction)psyco_microprotocols_adapt, METH_VARARGS, psyco_microprotocols_adapt_doc}, |
|
38808
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
206 {"enable_callback_tracebacks", (PyCFunction)enable_callback_tracebacks, METH_VARARGS, PyDoc_STR("Enable or disable callback functions throwing errors to stderr.")}, |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
207 {NULL, NULL} |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
208 }; |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
209 |
|
38808
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
210 struct _IntConstantPair { |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
211 char* constant_name; |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
212 int constant_value; |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
213 }; |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
214 |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
215 typedef struct _IntConstantPair IntConstantPair; |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
216 |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
217 static IntConstantPair _int_constants[] = { |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
218 {"PARSE_DECLTYPES", PARSE_DECLTYPES}, |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
219 {"PARSE_COLNAMES", PARSE_COLNAMES}, |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
220 |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
221 {"SQLITE_OK", SQLITE_OK}, |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
222 {"SQLITE_DENY", SQLITE_DENY}, |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
223 {"SQLITE_IGNORE", SQLITE_IGNORE}, |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
224 {"SQLITE_CREATE_INDEX", SQLITE_CREATE_INDEX}, |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
225 {"SQLITE_CREATE_TABLE", SQLITE_CREATE_TABLE}, |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
226 {"SQLITE_CREATE_TEMP_INDEX", SQLITE_CREATE_TEMP_INDEX}, |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
227 {"SQLITE_CREATE_TEMP_TABLE", SQLITE_CREATE_TEMP_TABLE}, |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
228 {"SQLITE_CREATE_TEMP_TRIGGER", SQLITE_CREATE_TEMP_TRIGGER}, |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
229 {"SQLITE_CREATE_TEMP_VIEW", SQLITE_CREATE_TEMP_VIEW}, |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
230 {"SQLITE_CREATE_TRIGGER", SQLITE_CREATE_TRIGGER}, |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
231 {"SQLITE_CREATE_VIEW", SQLITE_CREATE_VIEW}, |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
232 {"SQLITE_DELETE", SQLITE_DELETE}, |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
233 {"SQLITE_DROP_INDEX", SQLITE_DROP_INDEX}, |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
234 {"SQLITE_DROP_TABLE", SQLITE_DROP_TABLE}, |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
235 {"SQLITE_DROP_TEMP_INDEX", SQLITE_DROP_TEMP_INDEX}, |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
236 {"SQLITE_DROP_TEMP_TABLE", SQLITE_DROP_TEMP_TABLE}, |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
237 {"SQLITE_DROP_TEMP_TRIGGER", SQLITE_DROP_TEMP_TRIGGER}, |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
238 {"SQLITE_DROP_TEMP_VIEW", SQLITE_DROP_TEMP_VIEW}, |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
239 {"SQLITE_DROP_TRIGGER", SQLITE_DROP_TRIGGER}, |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
240 {"SQLITE_DROP_VIEW", SQLITE_DROP_VIEW}, |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
241 {"SQLITE_INSERT", SQLITE_INSERT}, |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
242 {"SQLITE_PRAGMA", SQLITE_PRAGMA}, |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
243 {"SQLITE_READ", SQLITE_READ}, |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
244 {"SQLITE_SELECT", SQLITE_SELECT}, |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
245 {"SQLITE_TRANSACTION", SQLITE_TRANSACTION}, |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
246 {"SQLITE_UPDATE", SQLITE_UPDATE}, |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
247 {"SQLITE_ATTACH", SQLITE_ATTACH}, |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
248 {"SQLITE_DETACH", SQLITE_DETACH}, |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
249 #if SQLITE_VERSION_NUMBER >= 3002001 |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
250 {"SQLITE_ALTER_TABLE", SQLITE_ALTER_TABLE}, |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
251 {"SQLITE_REINDEX", SQLITE_REINDEX}, |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
252 #endif |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
253 #if SQLITE_VERSION_NUMBER >= 3003000 |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
254 {"SQLITE_ANALYZE", SQLITE_ANALYZE}, |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
255 #endif |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
256 {(char*)NULL, 0} |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
257 }; |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
258 |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
259 PyMODINIT_FUNC init_sqlite3(void) |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
260 { |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
261 PyObject *module, *dict; |
|
37458
d27058c409df
Update to pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37362
diff
changeset
|
262 PyObject *tmp_obj; |
|
38808
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
263 int i; |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
264 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
265 module = Py_InitModule("_sqlite3", module_methods); |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
266 |
|
37458
d27058c409df
Update to pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37362
diff
changeset
|
267 if (!module || |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
268 (row_setup_types() < 0) || |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
269 (cursor_setup_types() < 0) || |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
270 (connection_setup_types() < 0) || |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
271 (cache_setup_types() < 0) || |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
272 (statement_setup_types() < 0) || |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
273 (prepare_protocol_setup_types() < 0) |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
274 ) { |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
275 return; |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
276 } |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
277 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
278 Py_INCREF(&ConnectionType); |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
279 PyModule_AddObject(module, "Connection", (PyObject*) &ConnectionType); |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
280 Py_INCREF(&CursorType); |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
281 PyModule_AddObject(module, "Cursor", (PyObject*) &CursorType); |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
282 Py_INCREF(&CacheType); |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
283 PyModule_AddObject(module, "Statement", (PyObject*)&StatementType); |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
284 Py_INCREF(&StatementType); |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
285 PyModule_AddObject(module, "Cache", (PyObject*) &CacheType); |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
286 Py_INCREF(&SQLitePrepareProtocolType); |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
287 PyModule_AddObject(module, "PrepareProtocol", (PyObject*) &SQLitePrepareProtocolType); |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
288 Py_INCREF(&RowType); |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
289 PyModule_AddObject(module, "Row", (PyObject*) &RowType); |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
290 |
|
37458
d27058c409df
Update to pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37362
diff
changeset
|
291 if (!(dict = PyModule_GetDict(module))) { |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
292 goto error; |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
293 } |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
294 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
295 /*** Create DB-API Exception hierarchy */ |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
296 |
|
37495
d3969aeba777
upgrade to final version of pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37458
diff
changeset
|
297 if (!(Error = PyErr_NewException(MODULE_NAME ".Error", PyExc_StandardError, NULL))) { |
|
37458
d27058c409df
Update to pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37362
diff
changeset
|
298 goto error; |
|
d27058c409df
Update to pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37362
diff
changeset
|
299 } |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
300 PyDict_SetItemString(dict, "Error", Error); |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
301 |
|
37495
d3969aeba777
upgrade to final version of pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37458
diff
changeset
|
302 if (!(Warning = PyErr_NewException(MODULE_NAME ".Warning", PyExc_StandardError, NULL))) { |
|
37458
d27058c409df
Update to pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37362
diff
changeset
|
303 goto error; |
|
d27058c409df
Update to pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37362
diff
changeset
|
304 } |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
305 PyDict_SetItemString(dict, "Warning", Warning); |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
306 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
307 /* Error subclasses */ |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
308 |
|
37495
d3969aeba777
upgrade to final version of pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37458
diff
changeset
|
309 if (!(InterfaceError = PyErr_NewException(MODULE_NAME ".InterfaceError", Error, NULL))) { |
|
37458
d27058c409df
Update to pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37362
diff
changeset
|
310 goto error; |
|
d27058c409df
Update to pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37362
diff
changeset
|
311 } |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
312 PyDict_SetItemString(dict, "InterfaceError", InterfaceError); |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
313 |
|
37495
d3969aeba777
upgrade to final version of pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37458
diff
changeset
|
314 if (!(DatabaseError = PyErr_NewException(MODULE_NAME ".DatabaseError", Error, NULL))) { |
|
37458
d27058c409df
Update to pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37362
diff
changeset
|
315 goto error; |
|
d27058c409df
Update to pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37362
diff
changeset
|
316 } |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
317 PyDict_SetItemString(dict, "DatabaseError", DatabaseError); |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
318 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
319 /* DatabaseError subclasses */ |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
320 |
|
37495
d3969aeba777
upgrade to final version of pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37458
diff
changeset
|
321 if (!(InternalError = PyErr_NewException(MODULE_NAME ".InternalError", DatabaseError, NULL))) { |
|
37458
d27058c409df
Update to pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37362
diff
changeset
|
322 goto error; |
|
d27058c409df
Update to pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37362
diff
changeset
|
323 } |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
324 PyDict_SetItemString(dict, "InternalError", InternalError); |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
325 |
|
37495
d3969aeba777
upgrade to final version of pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37458
diff
changeset
|
326 if (!(OperationalError = PyErr_NewException(MODULE_NAME ".OperationalError", DatabaseError, NULL))) { |
|
37458
d27058c409df
Update to pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37362
diff
changeset
|
327 goto error; |
|
d27058c409df
Update to pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37362
diff
changeset
|
328 } |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
329 PyDict_SetItemString(dict, "OperationalError", OperationalError); |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
330 |
|
37495
d3969aeba777
upgrade to final version of pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37458
diff
changeset
|
331 if (!(ProgrammingError = PyErr_NewException(MODULE_NAME ".ProgrammingError", DatabaseError, NULL))) { |
|
37458
d27058c409df
Update to pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37362
diff
changeset
|
332 goto error; |
|
d27058c409df
Update to pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37362
diff
changeset
|
333 } |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
334 PyDict_SetItemString(dict, "ProgrammingError", ProgrammingError); |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
335 |
|
37495
d3969aeba777
upgrade to final version of pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37458
diff
changeset
|
336 if (!(IntegrityError = PyErr_NewException(MODULE_NAME ".IntegrityError", DatabaseError,NULL))) { |
|
37458
d27058c409df
Update to pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37362
diff
changeset
|
337 goto error; |
|
d27058c409df
Update to pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37362
diff
changeset
|
338 } |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
339 PyDict_SetItemString(dict, "IntegrityError", IntegrityError); |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
340 |
|
37495
d3969aeba777
upgrade to final version of pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37458
diff
changeset
|
341 if (!(DataError = PyErr_NewException(MODULE_NAME ".DataError", DatabaseError, NULL))) { |
|
37458
d27058c409df
Update to pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37362
diff
changeset
|
342 goto error; |
|
d27058c409df
Update to pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37362
diff
changeset
|
343 } |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
344 PyDict_SetItemString(dict, "DataError", DataError); |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
345 |
|
37495
d3969aeba777
upgrade to final version of pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37458
diff
changeset
|
346 if (!(NotSupportedError = PyErr_NewException(MODULE_NAME ".NotSupportedError", DatabaseError, NULL))) { |
|
37458
d27058c409df
Update to pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37362
diff
changeset
|
347 goto error; |
|
d27058c409df
Update to pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37362
diff
changeset
|
348 } |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
349 PyDict_SetItemString(dict, "NotSupportedError", NotSupportedError); |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
350 |
|
37458
d27058c409df
Update to pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37362
diff
changeset
|
351 /* We just need "something" unique for OptimizedUnicode. It does not really |
|
d27058c409df
Update to pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37362
diff
changeset
|
352 * need to be a string subclass. Just anything that can act as a special |
|
d27058c409df
Update to pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37362
diff
changeset
|
353 * marker for us. So I pulled PyCell_Type out of my magic hat. |
|
d27058c409df
Update to pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37362
diff
changeset
|
354 */ |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
355 Py_INCREF((PyObject*)&PyCell_Type); |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
356 OptimizedUnicode = (PyObject*)&PyCell_Type; |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
357 PyDict_SetItemString(dict, "OptimizedUnicode", OptimizedUnicode); |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
358 |
|
38808
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
359 /* Set integer constants */ |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
360 for (i = 0; _int_constants[i].constant_name != 0; i++) { |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
361 tmp_obj = PyInt_FromLong(_int_constants[i].constant_value); |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
362 if (!tmp_obj) { |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
363 goto error; |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
364 } |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
365 PyDict_SetItemString(dict, _int_constants[i].constant_name, tmp_obj); |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
366 Py_DECREF(tmp_obj); |
|
37458
d27058c409df
Update to pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37362
diff
changeset
|
367 } |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
368 |
|
37458
d27058c409df
Update to pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37362
diff
changeset
|
369 if (!(tmp_obj = PyString_FromString(PYSQLITE_VERSION))) { |
|
d27058c409df
Update to pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37362
diff
changeset
|
370 goto error; |
|
d27058c409df
Update to pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37362
diff
changeset
|
371 } |
|
d27058c409df
Update to pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37362
diff
changeset
|
372 PyDict_SetItemString(dict, "version", tmp_obj); |
|
38543
75d681159329
More memory leaks from valgrind
Neal Norwitz <nnorwitz@gmail.com>
parents:
37938
diff
changeset
|
373 Py_DECREF(tmp_obj); |
|
37458
d27058c409df
Update to pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37362
diff
changeset
|
374 |
|
d27058c409df
Update to pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37362
diff
changeset
|
375 if (!(tmp_obj = PyString_FromString(sqlite3_libversion()))) { |
|
d27058c409df
Update to pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37362
diff
changeset
|
376 goto error; |
|
d27058c409df
Update to pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37362
diff
changeset
|
377 } |
|
d27058c409df
Update to pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37362
diff
changeset
|
378 PyDict_SetItemString(dict, "sqlite_version", tmp_obj); |
|
38543
75d681159329
More memory leaks from valgrind
Neal Norwitz <nnorwitz@gmail.com>
parents:
37938
diff
changeset
|
379 Py_DECREF(tmp_obj); |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
380 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
381 /* initialize microprotocols layer */ |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
382 microprotocols_init(dict); |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
383 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
384 /* initialize the default converters */ |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
385 converters_init(dict); |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
386 |
|
38808
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
387 _enable_callback_tracebacks = 0; |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
38543
diff
changeset
|
388 |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
389 /* Original comment form _bsddb.c in the Python core. This is also still |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
390 * needed nowadays for Python 2.3/2.4. |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
391 * |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
392 * PyEval_InitThreads is called here due to a quirk in python 1.5 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
393 * - 2.2.1 (at least) according to Russell Williamson <merel@wt.net>: |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
394 * The global interepreter lock is not initialized until the first |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
395 * thread is created using thread.start_new_thread() or fork() is |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
396 * called. that would cause the ALLOW_THREADS here to segfault due |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
397 * to a null pointer reference if no threads or child processes |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
398 * have been created. This works around that and is a no-op if |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
399 * threads have already been initialized. |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
400 * (see pybsddb-users mailing list post on 2002-08-07) |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
401 */ |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
402 PyEval_InitThreads(); |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
403 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
404 error: |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
405 if (PyErr_Occurred()) |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
406 { |
|
37495
d3969aeba777
upgrade to final version of pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37458
diff
changeset
|
407 PyErr_SetString(PyExc_ImportError, MODULE_NAME ": init failed"); |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
408 } |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
409 } |
