comparison _mysql.c @ 18:d55bfb1a4701 MySQLdb

Tons of changes from major refactoring/cleanup. This is all really broken right now. In particular, all results are returned as strings.
author adustman
date Fri, 14 Mar 2008 23:06:29 +0000
parents fa8974a41c76
children d301c95d8fd7
comparison
equal deleted inserted replaced
17:7c7a89123d65 18:d55bfb1a4701
1 #include "_mysql.h" 1 #include "_mysql.h"
2 2
3 extern PyTypeObject _mysql_ConnectionObject_Type; 3 PyObject *_mysql_MySQLError;
4 extern PyTypeObject _mysql_ResultObject_Type; 4 PyObject *_mysql_Warning;
5 PyObject *_mysql_Error;
6 PyObject *_mysql_DatabaseError;
7 PyObject *_mysql_InterfaceError;
8 PyObject *_mysql_DataError;
9 PyObject *_mysql_OperationalError;
10 PyObject *_mysql_IntegrityError;
11 PyObject *_mysql_InternalError;
12 PyObject *_mysql_ProgrammingError;
13 PyObject *_mysql_NotSupportedError;
14 PyObject *_mysql_error_map;
5 15
6 int _mysql_server_init_done = 0; 16 int _mysql_server_init_done = 0;
7 17
8 PyObject * 18 PyObject *
9 _mysql_Exception(_mysql_ConnectionObject *c) 19 _mysql_Exception(_mysql_ConnectionObject *c)
437 module = Py_InitModule4("_mysql", _mysql_methods, _mysql___doc__, 447 module = Py_InitModule4("_mysql", _mysql_methods, _mysql___doc__,
438 (PyObject *)NULL, PYTHON_API_VERSION); 448 (PyObject *)NULL, PYTHON_API_VERSION);
439 if (!module) return; /* this really should never happen */ 449 if (!module) return; /* this really should never happen */
440 _mysql_ConnectionObject_Type.ob_type = &PyType_Type; 450 _mysql_ConnectionObject_Type.ob_type = &PyType_Type;
441 _mysql_ResultObject_Type.ob_type = &PyType_Type; 451 _mysql_ResultObject_Type.ob_type = &PyType_Type;
452 _mysql_FieldObject_Type.ob_type = &PyType_Type;
442 #if PY_VERSION_HEX >= 0x02020000 453 #if PY_VERSION_HEX >= 0x02020000
443 _mysql_ConnectionObject_Type.tp_alloc = PyType_GenericAlloc; 454 _mysql_ConnectionObject_Type.tp_alloc = PyType_GenericAlloc;
444 _mysql_ConnectionObject_Type.tp_new = PyType_GenericNew; 455 _mysql_ConnectionObject_Type.tp_new = PyType_GenericNew;
445 _mysql_ConnectionObject_Type.tp_free = _PyObject_GC_Del; 456 _mysql_ConnectionObject_Type.tp_free = _PyObject_GC_Del;
446 _mysql_ResultObject_Type.tp_alloc = PyType_GenericAlloc; 457 _mysql_ResultObject_Type.tp_alloc = PyType_GenericAlloc;
447 _mysql_ResultObject_Type.tp_new = PyType_GenericNew; 458 _mysql_ResultObject_Type.tp_new = PyType_GenericNew;
448 _mysql_ResultObject_Type.tp_free = _PyObject_GC_Del; 459 _mysql_ResultObject_Type.tp_free = _PyObject_GC_Del;
460 _mysql_FieldObject_Type.tp_alloc = PyType_GenericAlloc;
461 _mysql_FieldObject_Type.tp_new = PyType_GenericNew;
462 _mysql_FieldObject_Type.tp_free = _PyObject_GC_Del;
449 #endif 463 #endif
450 464
451 if (!(dict = PyModule_GetDict(module))) goto error; 465 if (!(dict = PyModule_GetDict(module))) goto error;
452 if (PyDict_SetItemString(dict, "version_info", 466 if (PyDict_SetItemString(dict, "version_info",
453 PyRun_String(QUOTE(version_info), Py_eval_input, 467 PyRun_String(QUOTE(version_info), Py_eval_input,
462 Py_INCREF(&_mysql_ConnectionObject_Type); 476 Py_INCREF(&_mysql_ConnectionObject_Type);
463 if (PyDict_SetItemString(dict, "result", 477 if (PyDict_SetItemString(dict, "result",
464 (PyObject *)&_mysql_ResultObject_Type)) 478 (PyObject *)&_mysql_ResultObject_Type))
465 goto error; 479 goto error;
466 Py_INCREF(&_mysql_ResultObject_Type); 480 Py_INCREF(&_mysql_ResultObject_Type);
467 if (!(emod = PyImport_ImportModule("_mysql_exceptions"))) 481 if (PyDict_SetItemString(dict, "field",
482 (PyObject *)&_mysql_FieldObject_Type))
483 goto error;
484 Py_INCREF(&_mysql_FieldObject_Type);
485 if (!(emod = PyImport_ImportModule("MySQLdb.exceptions")))
468 goto error; 486 goto error;
469 if (!(edict = PyModule_GetDict(emod))) goto error; 487 if (!(edict = PyModule_GetDict(emod))) goto error;
470 if (!(_mysql_MySQLError = 488 if (!(_mysql_MySQLError =
471 _mysql_NewException(dict, edict, "MySQLError"))) 489 _mysql_NewException(dict, edict, "MySQLError")))
472 goto error; 490 goto error;