@@ -42,47 +42,52 @@ module _sqlite3
42
42
[clinic start generated code]*/
43
43
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=81e330492d57488e]*/
44
44
45
- // NOTE: This must equal sqlite3.Connection.__init__ argument spec!
46
- /*[clinic input]
47
- _sqlite3.connect as pysqlite_connect
48
-
49
- database: object
50
- timeout: double = 5.0
51
- detect_types: int = 0
52
- isolation_level: object = NULL
53
- check_same_thread: bool(accept={int}) = True
54
- factory: object(c_default='(PyObject*)clinic_state()->ConnectionType') = ConnectionType
55
- cached_statements: int = 128
56
- uri: bool = False
57
-
58
- Opens a connection to the SQLite database file database.
59
-
60
- You can use ":memory:" to open a database connection to a database that resides
61
- in RAM instead of on disk.
62
- [clinic start generated code]*/
45
+ PyDoc_STRVAR (pysqlite_connect__doc__ ,
46
+ "connect($module, /, database, timeout=5.0, detect_types=0,\n"
47
+ " isolation_level=<unrepresentable>, check_same_thread=True,\n"
48
+ " factory=ConnectionType, cached_statements=128, uri=False)\n"
49
+ "--\n"
50
+ "\n"
51
+ "Opens a connection to the SQLite database file database.\n"
52
+ "\n"
53
+ "You can use \":memory:\" to open a database connection to a database that resides\n"
54
+ "in RAM instead of on disk." );
55
+
56
+ #define PYSQLITE_CONNECT_METHODDEF \
57
+ {"connect", _PyCFunction_CAST(module_connect), METH_VARARGS|METH_KEYWORDS, pysqlite_connect__doc__},
63
58
64
59
static PyObject *
65
- pysqlite_connect_impl (PyObject * module , PyObject * database , double timeout ,
66
- int detect_types , PyObject * isolation_level ,
67
- int check_same_thread , PyObject * factory ,
68
- int cached_statements , int uri )
69
- /*[clinic end generated code: output=450ac9078b4868bb input=e16914663ddf93ce]*/
60
+ module_connect (PyObject * self , PyObject * args , PyObject * kwargs )
70
61
{
71
- if (isolation_level == NULL ) {
72
- isolation_level = PyUnicode_FromString ("" );
73
- if (isolation_level == NULL ) {
74
- return NULL ;
75
- }
62
+ /* Python seems to have no way of extracting a single keyword-arg at
63
+ * C-level, so this code is redundant with the one in connection_init in
64
+ * connection.c and must always be copied from there ... */
65
+ static char * kwlist [] = {
66
+ "database" , "timeout" , "detect_types" , "isolation_level" ,
67
+ "check_same_thread" , "factory" , "cached_statements" , "uri" ,
68
+ NULL
69
+ };
70
+ PyObject * database ;
71
+ int detect_types = 0 ;
72
+ PyObject * isolation_level ;
73
+ PyObject * factory = NULL ;
74
+ int check_same_thread = 1 ;
75
+ int cached_statements ;
76
+ int uri = 0 ;
77
+ double timeout = 5.0 ;
78
+
79
+ if (!PyArg_ParseTupleAndKeywords (args , kwargs , "O|diOiOip" , kwlist ,
80
+ & database , & timeout , & detect_types ,
81
+ & isolation_level , & check_same_thread ,
82
+ & factory , & cached_statements , & uri ))
83
+ {
84
+ return NULL ;
76
85
}
77
- else {
78
- Py_INCREF (isolation_level );
86
+ if (factory == NULL ) {
87
+ pysqlite_state * state = pysqlite_get_state (self );
88
+ factory = (PyObject * )state -> ConnectionType ;
79
89
}
80
- PyObject * res = PyObject_CallFunction (factory , "OdiOiOii" , database ,
81
- timeout , detect_types ,
82
- isolation_level , check_same_thread ,
83
- factory , cached_statements , uri );
84
- Py_DECREF (isolation_level );
85
- return res ;
90
+ return PyObject_Call (factory , args , kwargs );
86
91
}
87
92
88
93
/*[clinic input]
0 commit comments