Mercurial > p > mysql-python > mysqldb-2
comparison _mysql_connections.c @ 25:25c5d3b241ba MySQLdb
Start converting some some things to METH_NOARGS to save invocation time, add
a few tests to directly probe these internals.
SF Patch ID 2565515
author | kylev |
---|---|
date | Sat, 07 Feb 2009 20:42:50 +0000 |
parents | bb552e789992 |
children | fbf2470ea3d4 |
comparison
equal
deleted
inserted
replaced
24:2f4672764d39 | 25:25c5d3b241ba |
---|---|
328 "Close the connection. No further activity possible."; | 328 "Close the connection. No further activity possible."; |
329 | 329 |
330 static PyObject * | 330 static PyObject * |
331 _mysql_ConnectionObject_close( | 331 _mysql_ConnectionObject_close( |
332 _mysql_ConnectionObject *self, | 332 _mysql_ConnectionObject *self, |
333 PyObject *args) | 333 PyObject *unused) |
334 { | 334 { |
335 if (args) { | |
336 if (!PyArg_ParseTuple(args, "")) return NULL; | |
337 } | |
338 if (self->open) { | 335 if (self->open) { |
339 Py_BEGIN_ALLOW_THREADS | 336 Py_BEGIN_ALLOW_THREADS |
340 mysql_close(&(self->connection)); | 337 mysql_close(&(self->connection)); |
341 Py_END_ALLOW_THREADS | 338 Py_END_ALLOW_THREADS |
342 self->open = 0; | 339 self->open = 0; |
356 "; | 353 "; |
357 | 354 |
358 static PyObject * | 355 static PyObject * |
359 _mysql_ConnectionObject_affected_rows( | 356 _mysql_ConnectionObject_affected_rows( |
360 _mysql_ConnectionObject *self, | 357 _mysql_ConnectionObject *self, |
361 PyObject *args) | 358 PyObject *unused) |
362 { | 359 { |
363 if (!PyArg_ParseTuple(args, "")) return NULL; | |
364 check_connection(self); | 360 check_connection(self); |
365 return PyLong_FromUnsignedLongLong(mysql_affected_rows(&(self->connection))); | 361 return PyLong_FromUnsignedLongLong(mysql_affected_rows(&(self->connection))); |
366 } | 362 } |
367 | 363 |
368 static char _mysql_ConnectionObject_dump_debug_info__doc__[] = | 364 static char _mysql_ConnectionObject_dump_debug_info__doc__[] = |
372 "; | 368 "; |
373 | 369 |
374 static PyObject * | 370 static PyObject * |
375 _mysql_ConnectionObject_dump_debug_info( | 371 _mysql_ConnectionObject_dump_debug_info( |
376 _mysql_ConnectionObject *self, | 372 _mysql_ConnectionObject *self, |
377 PyObject *args) | 373 PyObject *unused) |
378 { | 374 { |
379 int err; | 375 int err; |
380 if (!PyArg_ParseTuple(args, "")) return NULL; | 376 |
381 check_connection(self); | 377 check_connection(self); |
382 Py_BEGIN_ALLOW_THREADS | 378 Py_BEGIN_ALLOW_THREADS |
383 err = mysql_dump_debug_info(&(self->connection)); | 379 err = mysql_dump_debug_info(&(self->connection)); |
384 Py_END_ALLOW_THREADS | 380 Py_END_ALLOW_THREADS |
385 if (err) return _mysql_Exception(self); | 381 if (err) return _mysql_Exception(self); |
409 #endif | 405 #endif |
410 Py_END_ALLOW_THREADS | 406 Py_END_ALLOW_THREADS |
411 if (err) return _mysql_Exception(self); | 407 if (err) return _mysql_Exception(self); |
412 Py_INCREF(Py_None); | 408 Py_INCREF(Py_None); |
413 return Py_None; | 409 return Py_None; |
414 } | 410 } |
415 | 411 |
416 static char _mysql_ConnectionObject_commit__doc__[] = | 412 static char _mysql_ConnectionObject_commit__doc__[] = |
417 "Commits the current transaction\n\ | 413 "Commits the current transaction\n\ |
418 "; | 414 "; |
419 static PyObject * | 415 static PyObject * |
420 _mysql_ConnectionObject_commit( | 416 _mysql_ConnectionObject_commit( |
421 _mysql_ConnectionObject *self, | 417 _mysql_ConnectionObject *self, |
422 PyObject *args) | 418 PyObject *unused) |
423 { | 419 { |
424 int err; | 420 int err; |
425 if (!PyArg_ParseTuple(args, "")) return NULL; | 421 |
426 Py_BEGIN_ALLOW_THREADS | 422 Py_BEGIN_ALLOW_THREADS |
427 #if MYSQL_VERSION_ID >= 40100 | 423 #if MYSQL_VERSION_ID >= 40100 |
428 err = mysql_commit(&(self->connection)); | 424 err = mysql_commit(&(self->connection)); |
429 #else | 425 #else |
430 err = mysql_query(&(self->connection), "COMMIT"); | 426 err = mysql_query(&(self->connection), "COMMIT"); |
431 #endif | 427 #endif |
432 Py_END_ALLOW_THREADS | 428 Py_END_ALLOW_THREADS |
433 if (err) return _mysql_Exception(self); | 429 if (err) return _mysql_Exception(self); |
434 Py_INCREF(Py_None); | 430 Py_INCREF(Py_None); |
435 return Py_None; | 431 return Py_None; |
436 } | 432 } |
437 | 433 |
438 static char _mysql_ConnectionObject_rollback__doc__[] = | 434 static char _mysql_ConnectionObject_rollback__doc__[] = |
439 "Rolls backs the current transaction\n\ | 435 "Rolls backs the current transaction\n\ |
440 "; | 436 "; |
441 static PyObject * | 437 static PyObject * |
442 _mysql_ConnectionObject_rollback( | 438 _mysql_ConnectionObject_rollback( |
443 _mysql_ConnectionObject *self, | 439 _mysql_ConnectionObject *self, |
444 PyObject *args) | 440 PyObject *unused) |
445 { | 441 { |
446 int err; | 442 int err; |
447 if (!PyArg_ParseTuple(args, "")) return NULL; | 443 |
448 Py_BEGIN_ALLOW_THREADS | 444 Py_BEGIN_ALLOW_THREADS |
449 #if MYSQL_VERSION_ID >= 40100 | 445 #if MYSQL_VERSION_ID >= 40100 |
450 err = mysql_rollback(&(self->connection)); | 446 err = mysql_rollback(&(self->connection)); |
451 #else | 447 #else |
452 err = mysql_query(&(self->connection), "ROLLBACK"); | 448 err = mysql_query(&(self->connection), "ROLLBACK"); |
453 #endif | 449 #endif |
454 Py_END_ALLOW_THREADS | 450 Py_END_ALLOW_THREADS |
455 if (err) return _mysql_Exception(self); | 451 if (err) return _mysql_Exception(self); |
456 Py_INCREF(Py_None); | 452 Py_INCREF(Py_None); |
457 return Py_None; | 453 return Py_None; |
458 } | 454 } |
459 | 455 |
460 static char _mysql_ConnectionObject_next_result__doc__[] = | 456 static char _mysql_ConnectionObject_next_result__doc__[] = |
461 "If more query results exist, next_result() reads the next query\n\ | 457 "If more query results exist, next_result() reads the next query\n\ |
462 results and returns the status back to application.\n\ | 458 results and returns the status back to application.\n\ |
463 \n\ | 459 \n\ |
471 Non-standard.\n\ | 467 Non-standard.\n\ |
472 "; | 468 "; |
473 static PyObject * | 469 static PyObject * |
474 _mysql_ConnectionObject_next_result( | 470 _mysql_ConnectionObject_next_result( |
475 _mysql_ConnectionObject *self, | 471 _mysql_ConnectionObject *self, |
476 PyObject *args) | 472 PyObject *unused) |
477 { | 473 { |
478 int err; | 474 int err; |
479 if (!PyArg_ParseTuple(args, "")) return NULL; | 475 |
480 Py_BEGIN_ALLOW_THREADS | 476 Py_BEGIN_ALLOW_THREADS |
481 #if MYSQL_VERSION_ID >= 40100 | 477 #if MYSQL_VERSION_ID >= 40100 |
482 err = mysql_next_result(&(self->connection)); | 478 err = mysql_next_result(&(self->connection)); |
483 #else | 479 #else |
484 err = -1; | 480 err = -1; |
485 #endif | 481 #endif |
486 Py_END_ALLOW_THREADS | 482 Py_END_ALLOW_THREADS |
487 if (err > 0) return _mysql_Exception(self); | 483 if (err > 0) return _mysql_Exception(self); |
488 return PyInt_FromLong(err); | 484 return PyInt_FromLong(err); |
489 } | 485 } |
490 | 486 |
491 #if MYSQL_VERSION_ID >= 40100 | 487 #if MYSQL_VERSION_ID >= 40100 |
492 | 488 |
493 static char _mysql_ConnectionObject_set_server_option__doc__[] = | 489 static char _mysql_ConnectionObject_set_server_option__doc__[] = |
494 "set_server_option(option) -- Enables or disables an option\n\ | 490 "set_server_option(option) -- Enables or disables an option\n\ |
524 Non-standard.\n\ | 520 Non-standard.\n\ |
525 "; | 521 "; |
526 static PyObject * | 522 static PyObject * |
527 _mysql_ConnectionObject_sqlstate( | 523 _mysql_ConnectionObject_sqlstate( |
528 _mysql_ConnectionObject *self, | 524 _mysql_ConnectionObject *self, |
529 PyObject *args) | 525 PyObject *unused) |
530 { | 526 { |
531 if (!PyArg_ParseTuple(args, "")) return NULL; | |
532 return PyString_FromString(mysql_sqlstate(&(self->connection))); | 527 return PyString_FromString(mysql_sqlstate(&(self->connection))); |
533 } | 528 } |
534 | 529 |
535 static char _mysql_ConnectionObject_warning_count__doc__[] = | 530 static char _mysql_ConnectionObject_warning_count__doc__[] = |
536 "Returns the number of warnings generated during execution\n\ | 531 "Returns the number of warnings generated during execution\n\ |
537 of the previous SQL statement.\n\ | 532 of the previous SQL statement.\n\ |
538 \n\ | 533 \n\ |
539 Non-standard.\n\ | 534 Non-standard.\n\ |
540 "; | 535 "; |
541 static PyObject * | 536 static PyObject * |
542 _mysql_ConnectionObject_warning_count( | 537 _mysql_ConnectionObject_warning_count( |
543 _mysql_ConnectionObject *self, | 538 _mysql_ConnectionObject *self, |
544 PyObject *args) | 539 PyObject *unused) |
545 { | 540 { |
546 if (!PyArg_ParseTuple(args, "")) return NULL; | |
547 return PyInt_FromLong(mysql_warning_count(&(self->connection))); | 541 return PyInt_FromLong(mysql_warning_count(&(self->connection))); |
548 } | 542 } |
549 | 543 |
550 #endif | 544 #endif |
551 | 545 |
552 static char _mysql_ConnectionObject_errno__doc__[] = | 546 static char _mysql_ConnectionObject_errno__doc__[] = |
553 "Returns the error code for the most recently invoked API function\n\ | 547 "Returns the error code for the most recently invoked API function\n\ |
556 "; | 550 "; |
557 | 551 |
558 static PyObject * | 552 static PyObject * |
559 _mysql_ConnectionObject_errno( | 553 _mysql_ConnectionObject_errno( |
560 _mysql_ConnectionObject *self, | 554 _mysql_ConnectionObject *self, |
561 PyObject *args) | 555 PyObject *unused) |
562 { | 556 { |
563 if (!PyArg_ParseTuple(args, "")) return NULL; | |
564 check_connection(self); | 557 check_connection(self); |
565 return PyInt_FromLong((long)mysql_errno(&(self->connection))); | 558 return PyInt_FromLong((long)mysql_errno(&(self->connection))); |
566 } | 559 } |
567 | 560 |
568 static char _mysql_ConnectionObject_error__doc__[] = | 561 static char _mysql_ConnectionObject_error__doc__[] = |
572 "; | 565 "; |
573 | 566 |
574 static PyObject * | 567 static PyObject * |
575 _mysql_ConnectionObject_error( | 568 _mysql_ConnectionObject_error( |
576 _mysql_ConnectionObject *self, | 569 _mysql_ConnectionObject *self, |
577 PyObject *args) | 570 PyObject *unused) |
578 { | 571 { |
579 if (!PyArg_ParseTuple(args, "")) return NULL; | |
580 check_connection(self); | 572 check_connection(self); |
581 return PyString_FromString(mysql_error(&(self->connection))); | 573 return PyString_FromString(mysql_error(&(self->connection))); |
582 } | 574 } |
583 | 575 |
584 #if MYSQL_VERSION_ID >= 32303 | 576 #if MYSQL_VERSION_ID >= 32303 |
629 "; | 621 "; |
630 | 622 |
631 static PyObject * | 623 static PyObject * |
632 _mysql_ConnectionObject_character_set_name( | 624 _mysql_ConnectionObject_character_set_name( |
633 _mysql_ConnectionObject *self, | 625 _mysql_ConnectionObject *self, |
634 PyObject *args) | 626 PyObject *unused) |
635 { | 627 { |
636 const char *s; | 628 const char *s; |
637 if (!PyArg_ParseTuple(args, "")) return NULL; | 629 |
638 check_connection(self); | 630 check_connection(self); |
639 #if MYSQL_VERSION_ID >= 32321 | 631 #if MYSQL_VERSION_ID >= 32321 |
640 s = mysql_character_set_name(&(self->connection)); | 632 s = mysql_character_set_name(&(self->connection)); |
641 #else | 633 #else |
642 s = "latin1"; | 634 s = "latin1"; |
691 "; | 683 "; |
692 | 684 |
693 static PyObject * | 685 static PyObject * |
694 _mysql_ConnectionObject_get_character_set_info( | 686 _mysql_ConnectionObject_get_character_set_info( |
695 _mysql_ConnectionObject *self, | 687 _mysql_ConnectionObject *self, |
696 PyObject *args) | 688 PyObject *unused) |
697 { | 689 { |
698 PyObject *result; | 690 PyObject *result; |
699 MY_CHARSET_INFO cs; | 691 MY_CHARSET_INFO cs; |
700 | 692 |
701 if (!PyArg_ParseTuple(args, "")) return NULL; | |
702 check_connection(self); | 693 check_connection(self); |
703 mysql_get_character_set_info(&(self->connection), &cs); | 694 mysql_get_character_set_info(&(self->connection), &cs); |
704 if (!(result = PyDict_New())) return NULL; | 695 if (!(result = PyDict_New())) return NULL; |
705 if (cs.csname) | 696 if (cs.csname) |
706 PyDict_SetItemString(result, "name", PyString_FromString(cs.csname)); | 697 PyDict_SetItemString(result, "name", PyString_FromString(cs.csname)); |
722 "; | 713 "; |
723 | 714 |
724 static PyObject * | 715 static PyObject * |
725 _mysql_ConnectionObject_get_host_info( | 716 _mysql_ConnectionObject_get_host_info( |
726 _mysql_ConnectionObject *self, | 717 _mysql_ConnectionObject *self, |
727 PyObject *args) | 718 PyObject *unused) |
728 { | 719 { |
729 if (!PyArg_ParseTuple(args, "")) return NULL; | |
730 check_connection(self); | 720 check_connection(self); |
731 return PyString_FromString(mysql_get_host_info(&(self->connection))); | 721 return PyString_FromString(mysql_get_host_info(&(self->connection))); |
732 } | 722 } |
733 | 723 |
734 static char _mysql_ConnectionObject_get_proto_info__doc__[] = | 724 static char _mysql_ConnectionObject_get_proto_info__doc__[] = |
737 "; | 727 "; |
738 | 728 |
739 static PyObject * | 729 static PyObject * |
740 _mysql_ConnectionObject_get_proto_info( | 730 _mysql_ConnectionObject_get_proto_info( |
741 _mysql_ConnectionObject *self, | 731 _mysql_ConnectionObject *self, |
742 PyObject *args) | 732 PyObject *unused) |
743 { | 733 { |
744 if (!PyArg_ParseTuple(args, "")) return NULL; | |
745 check_connection(self); | 734 check_connection(self); |
746 return PyInt_FromLong((long)mysql_get_proto_info(&(self->connection))); | 735 return PyInt_FromLong((long)mysql_get_proto_info(&(self->connection))); |
747 } | 736 } |
748 | 737 |
749 static char _mysql_ConnectionObject_get_server_info__doc__[] = | 738 static char _mysql_ConnectionObject_get_server_info__doc__[] = |
752 "; | 741 "; |
753 | 742 |
754 static PyObject * | 743 static PyObject * |
755 _mysql_ConnectionObject_get_server_info( | 744 _mysql_ConnectionObject_get_server_info( |
756 _mysql_ConnectionObject *self, | 745 _mysql_ConnectionObject *self, |
757 PyObject *args) | 746 PyObject *unused) |
758 { | 747 { |
759 if (!PyArg_ParseTuple(args, "")) return NULL; | |
760 check_connection(self); | 748 check_connection(self); |
761 return PyString_FromString(mysql_get_server_info(&(self->connection))); | 749 return PyString_FromString(mysql_get_server_info(&(self->connection))); |
762 } | 750 } |
763 | 751 |
764 static char _mysql_ConnectionObject_info__doc__[] = | 752 static char _mysql_ConnectionObject_info__doc__[] = |
768 "; | 756 "; |
769 | 757 |
770 static PyObject * | 758 static PyObject * |
771 _mysql_ConnectionObject_info( | 759 _mysql_ConnectionObject_info( |
772 _mysql_ConnectionObject *self, | 760 _mysql_ConnectionObject *self, |
773 PyObject *args) | 761 PyObject *unused) |
774 { | 762 { |
775 const char *s; | 763 const char *s; |
776 if (!PyArg_ParseTuple(args, "")) return NULL; | 764 |
777 check_connection(self); | 765 check_connection(self); |
778 s = mysql_info(&(self->connection)); | 766 s = mysql_info(&(self->connection)); |
779 if (s) return PyString_FromString(s); | 767 if (s) return PyString_FromString(s); |
780 Py_INCREF(Py_None); | 768 Py_INCREF(Py_None); |
781 return Py_None; | 769 return Py_None; |
803 " ; | 791 " ; |
804 | 792 |
805 static PyObject * | 793 static PyObject * |
806 _mysql_ConnectionObject_insert_id( | 794 _mysql_ConnectionObject_insert_id( |
807 _mysql_ConnectionObject *self, | 795 _mysql_ConnectionObject *self, |
808 PyObject *args) | 796 PyObject *unused) |
809 { | 797 { |
810 my_ulonglong r; | 798 my_ulonglong r; |
811 if (!PyArg_ParseTuple(args, "")) return NULL; | 799 |
812 check_connection(self); | 800 check_connection(self); |
813 Py_BEGIN_ALLOW_THREADS | 801 Py_BEGIN_ALLOW_THREADS |
814 r = mysql_insert_id(&(self->connection)); | 802 r = mysql_insert_id(&(self->connection)); |
815 Py_END_ALLOW_THREADS | 803 Py_END_ALLOW_THREADS |
816 return PyLong_FromUnsignedLongLong(r); | 804 return PyLong_FromUnsignedLongLong(r); |
844 "; | 832 "; |
845 | 833 |
846 static PyObject * | 834 static PyObject * |
847 _mysql_ConnectionObject_field_count( | 835 _mysql_ConnectionObject_field_count( |
848 _mysql_ConnectionObject *self, | 836 _mysql_ConnectionObject *self, |
849 PyObject *args) | 837 PyObject *unused) |
850 { | 838 { |
851 if (!PyArg_ParseTuple(args, "")) return NULL; | |
852 check_connection(self); | 839 check_connection(self); |
853 #if MYSQL_VERSION_ID < 32224 | 840 #if MYSQL_VERSION_ID < 32224 |
854 return PyInt_FromLong((long)mysql_num_fields(&(self->connection))); | 841 return PyInt_FromLong((long)mysql_num_fields(&(self->connection))); |
855 #else | 842 #else |
856 return PyInt_FromLong((long)mysql_field_count(&(self->connection))); | 843 return PyInt_FromLong((long)mysql_field_count(&(self->connection))); |
857 #endif | 844 #endif |
858 } | 845 } |
859 | 846 |
860 static char _mysql_ConnectionObject_ping__doc__[] = | 847 static char _mysql_ConnectionObject_ping__doc__[] = |
861 "Checks whether or not the connection to the server is\n\ | 848 "Checks whether or not the connection to the server is\n\ |
862 working. If it has gone down, an automatic reconnection is\n\ | 849 working. If it has gone down, an automatic reconnection is\n\ |
863 attempted.\n\ | 850 attempted.\n\ |
952 "; | 939 "; |
953 | 940 |
954 static PyObject * | 941 static PyObject * |
955 _mysql_ConnectionObject_shutdown( | 942 _mysql_ConnectionObject_shutdown( |
956 _mysql_ConnectionObject *self, | 943 _mysql_ConnectionObject *self, |
957 PyObject *args) | 944 PyObject *unused) |
958 { | 945 { |
959 int r; | 946 int r; |
960 if (!PyArg_ParseTuple(args, "")) return NULL; | 947 |
961 check_connection(self); | 948 check_connection(self); |
962 Py_BEGIN_ALLOW_THREADS | 949 Py_BEGIN_ALLOW_THREADS |
963 r = mysql_shutdown(&(self->connection) | 950 r = mysql_shutdown(&(self->connection) |
964 #if MYSQL_VERSION_ID >= 40103 | 951 #if MYSQL_VERSION_ID >= 40103 |
965 , SHUTDOWN_DEFAULT | 952 , SHUTDOWN_DEFAULT |
979 "; | 966 "; |
980 | 967 |
981 static PyObject * | 968 static PyObject * |
982 _mysql_ConnectionObject_stat( | 969 _mysql_ConnectionObject_stat( |
983 _mysql_ConnectionObject *self, | 970 _mysql_ConnectionObject *self, |
984 PyObject *args) | 971 PyObject *unused) |
985 { | 972 { |
986 const char *s; | 973 const char *s; |
987 if (!PyArg_ParseTuple(args, "")) return NULL; | 974 |
988 check_connection(self); | 975 check_connection(self); |
989 Py_BEGIN_ALLOW_THREADS | 976 Py_BEGIN_ALLOW_THREADS |
990 s = mysql_stat(&(self->connection)); | 977 s = mysql_stat(&(self->connection)); |
991 Py_END_ALLOW_THREADS | 978 Py_END_ALLOW_THREADS |
992 if (!s) return _mysql_Exception(self); | 979 if (!s) return _mysql_Exception(self); |
1000 "; | 987 "; |
1001 | 988 |
1002 static PyObject * | 989 static PyObject * |
1003 _mysql_ConnectionObject_store_result( | 990 _mysql_ConnectionObject_store_result( |
1004 _mysql_ConnectionObject *self, | 991 _mysql_ConnectionObject *self, |
1005 PyObject *args) | 992 PyObject *unused) |
1006 { | 993 { |
1007 PyObject *arglist=NULL, *kwarglist=NULL, *result=NULL; | 994 PyObject *arglist=NULL, *kwarglist=NULL, *result=NULL; |
1008 _mysql_ResultObject *r=NULL; | 995 _mysql_ResultObject *r=NULL; |
1009 | 996 |
1010 if (!PyArg_ParseTuple(args, "")) return NULL; | |
1011 check_connection(self); | 997 check_connection(self); |
1012 arglist = Py_BuildValue("(OiO)", self, 0, self->converter); | 998 arglist = Py_BuildValue("(OiO)", self, 0, self->converter); |
1013 if (!arglist) goto error; | 999 if (!arglist) goto error; |
1014 kwarglist = PyDict_New(); | 1000 kwarglist = PyDict_New(); |
1015 if (!kwarglist) goto error; | 1001 if (!kwarglist) goto error; |
1041 Non-standard."; | 1027 Non-standard."; |
1042 | 1028 |
1043 static PyObject * | 1029 static PyObject * |
1044 _mysql_ConnectionObject_thread_id( | 1030 _mysql_ConnectionObject_thread_id( |
1045 _mysql_ConnectionObject *self, | 1031 _mysql_ConnectionObject *self, |
1046 PyObject *args) | 1032 PyObject *unused) |
1047 { | 1033 { |
1048 unsigned long pid; | 1034 unsigned long pid; |
1049 if (!PyArg_ParseTuple(args, "")) return NULL; | 1035 |
1050 check_connection(self); | 1036 check_connection(self); |
1051 Py_BEGIN_ALLOW_THREADS | 1037 Py_BEGIN_ALLOW_THREADS |
1052 pid = mysql_thread_id(&(self->connection)); | 1038 pid = mysql_thread_id(&(self->connection)); |
1053 Py_END_ALLOW_THREADS | 1039 Py_END_ALLOW_THREADS |
1054 return PyInt_FromLong((long)pid); | 1040 return PyInt_FromLong((long)pid); |
1061 "; | 1047 "; |
1062 | 1048 |
1063 static PyObject * | 1049 static PyObject * |
1064 _mysql_ConnectionObject_use_result( | 1050 _mysql_ConnectionObject_use_result( |
1065 _mysql_ConnectionObject *self, | 1051 _mysql_ConnectionObject *self, |
1066 PyObject *args) | 1052 PyObject *unused) |
1067 { | 1053 { |
1068 PyObject *arglist=NULL, *kwarglist=NULL, *result=NULL; | 1054 PyObject *arglist=NULL, *kwarglist=NULL, *result=NULL; |
1069 _mysql_ResultObject *r=NULL; | 1055 _mysql_ResultObject *r=NULL; |
1070 | 1056 |
1071 if (!PyArg_ParseTuple(args, "")) return NULL; | |
1072 check_connection(self); | 1057 check_connection(self); |
1073 arglist = Py_BuildValue("(OiO)", self, 1, self->converter); | 1058 arglist = Py_BuildValue("(OiO)", self, 1, self->converter); |
1074 if (!arglist) return NULL; | 1059 if (!arglist) return NULL; |
1075 kwarglist = PyDict_New(); | 1060 kwarglist = PyDict_New(); |
1076 if (!kwarglist) goto error; | 1061 if (!kwarglist) goto error; |
1121 | 1106 |
1122 static PyMethodDef _mysql_ConnectionObject_methods[] = { | 1107 static PyMethodDef _mysql_ConnectionObject_methods[] = { |
1123 { | 1108 { |
1124 "affected_rows", | 1109 "affected_rows", |
1125 (PyCFunction)_mysql_ConnectionObject_affected_rows, | 1110 (PyCFunction)_mysql_ConnectionObject_affected_rows, |
1126 METH_VARARGS, | 1111 METH_NOARGS, |
1127 _mysql_ConnectionObject_affected_rows__doc__ | 1112 _mysql_ConnectionObject_affected_rows__doc__ |
1128 }, | 1113 }, |
1129 { | 1114 { |
1130 "autocommit", | 1115 "autocommit", |
1131 (PyCFunction)_mysql_ConnectionObject_autocommit, | 1116 (PyCFunction)_mysql_ConnectionObject_autocommit, |
1133 _mysql_ConnectionObject_autocommit__doc__ | 1118 _mysql_ConnectionObject_autocommit__doc__ |
1134 }, | 1119 }, |
1135 { | 1120 { |
1136 "commit", | 1121 "commit", |
1137 (PyCFunction)_mysql_ConnectionObject_commit, | 1122 (PyCFunction)_mysql_ConnectionObject_commit, |
1138 METH_VARARGS, | 1123 METH_NOARGS, |
1139 _mysql_ConnectionObject_commit__doc__ | 1124 _mysql_ConnectionObject_commit__doc__ |
1140 }, | 1125 }, |
1141 { | 1126 { |
1142 "rollback", | 1127 "rollback", |
1143 (PyCFunction)_mysql_ConnectionObject_rollback, | 1128 (PyCFunction)_mysql_ConnectionObject_rollback, |
1144 METH_VARARGS, | 1129 METH_NOARGS, |
1145 _mysql_ConnectionObject_rollback__doc__ | 1130 _mysql_ConnectionObject_rollback__doc__ |
1146 }, | 1131 }, |
1147 { | 1132 { |
1148 "next_result", | 1133 "next_result", |
1149 (PyCFunction)_mysql_ConnectionObject_next_result, | 1134 (PyCFunction)_mysql_ConnectionObject_next_result, |
1150 METH_VARARGS, | 1135 METH_NOARGS, |
1151 _mysql_ConnectionObject_next_result__doc__ | 1136 _mysql_ConnectionObject_next_result__doc__ |
1152 }, | 1137 }, |
1153 #if MYSQL_VERSION_ID >= 40100 | 1138 #if MYSQL_VERSION_ID >= 40100 |
1154 { | 1139 { |
1155 "set_server_option", | 1140 "set_server_option", |
1158 _mysql_ConnectionObject_set_server_option__doc__ | 1143 _mysql_ConnectionObject_set_server_option__doc__ |
1159 }, | 1144 }, |
1160 { | 1145 { |
1161 "sqlstate", | 1146 "sqlstate", |
1162 (PyCFunction)_mysql_ConnectionObject_sqlstate, | 1147 (PyCFunction)_mysql_ConnectionObject_sqlstate, |
1163 METH_VARARGS, | 1148 METH_NOARGS, |
1164 _mysql_ConnectionObject_sqlstate__doc__ | 1149 _mysql_ConnectionObject_sqlstate__doc__ |
1165 }, | 1150 }, |
1166 { | 1151 { |
1167 "warning_count", | 1152 "warning_count", |
1168 (PyCFunction)_mysql_ConnectionObject_warning_count, | 1153 (PyCFunction)_mysql_ConnectionObject_warning_count, |
1169 METH_VARARGS, | 1154 METH_NOARGS, |
1170 _mysql_ConnectionObject_warning_count__doc__ | 1155 _mysql_ConnectionObject_warning_count__doc__ |
1171 }, | 1156 }, |
1172 #endif | 1157 #endif |
1173 #if MYSQL_VERSION_ID >= 32303 | 1158 #if MYSQL_VERSION_ID >= 32303 |
1174 { | 1159 { |
1179 }, | 1164 }, |
1180 #endif | 1165 #endif |
1181 { | 1166 { |
1182 "character_set_name", | 1167 "character_set_name", |
1183 (PyCFunction)_mysql_ConnectionObject_character_set_name, | 1168 (PyCFunction)_mysql_ConnectionObject_character_set_name, |
1184 METH_VARARGS, | 1169 METH_NOARGS, |
1185 _mysql_ConnectionObject_character_set_name__doc__ | 1170 _mysql_ConnectionObject_character_set_name__doc__ |
1186 }, | 1171 }, |
1187 #if MYSQL_VERSION_ID >= 50007 | 1172 #if MYSQL_VERSION_ID >= 50007 |
1188 { | 1173 { |
1189 "set_character_set", | 1174 "set_character_set", |
1201 }, | 1186 }, |
1202 #endif | 1187 #endif |
1203 { | 1188 { |
1204 "close", | 1189 "close", |
1205 (PyCFunction)_mysql_ConnectionObject_close, | 1190 (PyCFunction)_mysql_ConnectionObject_close, |
1206 METH_VARARGS, | 1191 METH_NOARGS, |
1207 _mysql_ConnectionObject_close__doc__ | 1192 _mysql_ConnectionObject_close__doc__ |
1208 }, | 1193 }, |
1209 { | 1194 { |
1210 "dump_debug_info", | 1195 "dump_debug_info", |
1211 (PyCFunction)_mysql_ConnectionObject_dump_debug_info, | 1196 (PyCFunction)_mysql_ConnectionObject_dump_debug_info, |
1212 METH_VARARGS, | 1197 METH_NOARGS, |
1213 _mysql_ConnectionObject_dump_debug_info__doc__ | 1198 _mysql_ConnectionObject_dump_debug_info__doc__ |
1214 }, | 1199 }, |
1215 { | 1200 { |
1216 "escape", | 1201 "escape", |
1217 (PyCFunction)_mysql_escape, | 1202 (PyCFunction)_mysql_escape, |
1225 _mysql_escape_string__doc__ | 1210 _mysql_escape_string__doc__ |
1226 }, | 1211 }, |
1227 { | 1212 { |
1228 "error", | 1213 "error", |
1229 (PyCFunction)_mysql_ConnectionObject_error, | 1214 (PyCFunction)_mysql_ConnectionObject_error, |
1230 METH_VARARGS, | 1215 METH_NOARGS, |
1231 _mysql_ConnectionObject_error__doc__ | 1216 _mysql_ConnectionObject_error__doc__ |
1232 }, | 1217 }, |
1233 { | 1218 { |
1234 "errno", | 1219 "errno", |
1235 (PyCFunction)_mysql_ConnectionObject_errno, | 1220 (PyCFunction)_mysql_ConnectionObject_errno, |
1236 METH_VARARGS, | 1221 METH_NOARGS, |
1237 _mysql_ConnectionObject_errno__doc__ | 1222 _mysql_ConnectionObject_errno__doc__ |
1238 }, | 1223 }, |
1239 { | 1224 { |
1240 "field_count", | 1225 "field_count", |
1241 (PyCFunction)_mysql_ConnectionObject_field_count, | 1226 (PyCFunction)_mysql_ConnectionObject_field_count, |
1242 METH_VARARGS, | 1227 METH_NOARGS, |
1243 _mysql_ConnectionObject_field_count__doc__ | 1228 _mysql_ConnectionObject_field_count__doc__ |
1244 }, | 1229 }, |
1245 { | 1230 { |
1246 "get_host_info", | 1231 "get_host_info", |
1247 (PyCFunction)_mysql_ConnectionObject_get_host_info, | 1232 (PyCFunction)_mysql_ConnectionObject_get_host_info, |
1248 METH_VARARGS, | 1233 METH_NOARGS, |
1249 _mysql_ConnectionObject_get_host_info__doc__ | 1234 _mysql_ConnectionObject_get_host_info__doc__ |
1250 }, | 1235 }, |
1251 { | 1236 { |
1252 "get_proto_info", | 1237 "get_proto_info", |
1253 (PyCFunction)_mysql_ConnectionObject_get_proto_info, | 1238 (PyCFunction)_mysql_ConnectionObject_get_proto_info, |
1254 METH_VARARGS, | 1239 METH_NOARGS, |
1255 _mysql_ConnectionObject_get_proto_info__doc__ | 1240 _mysql_ConnectionObject_get_proto_info__doc__ |
1256 }, | 1241 }, |
1257 { | 1242 { |
1258 "get_server_info", | 1243 "get_server_info", |
1259 (PyCFunction)_mysql_ConnectionObject_get_server_info, | 1244 (PyCFunction)_mysql_ConnectionObject_get_server_info, |
1260 METH_VARARGS, | 1245 METH_NOARGS, |
1261 _mysql_ConnectionObject_get_server_info__doc__ | 1246 _mysql_ConnectionObject_get_server_info__doc__ |
1262 }, | 1247 }, |
1263 { | 1248 { |
1264 "info", | 1249 "info", |
1265 (PyCFunction)_mysql_ConnectionObject_info, | 1250 (PyCFunction)_mysql_ConnectionObject_info, |
1266 METH_VARARGS, | 1251 METH_NOARGS, |
1267 _mysql_ConnectionObject_info__doc__ | 1252 _mysql_ConnectionObject_info__doc__ |
1268 }, | 1253 }, |
1269 { | 1254 { |
1270 "insert_id", | 1255 "insert_id", |
1271 (PyCFunction)_mysql_ConnectionObject_insert_id, | 1256 (PyCFunction)_mysql_ConnectionObject_insert_id, |
1272 METH_VARARGS, | 1257 METH_NOARGS, |
1273 _mysql_ConnectionObject_insert_id__doc__ | 1258 _mysql_ConnectionObject_insert_id__doc__ |
1274 }, | 1259 }, |
1275 { | 1260 { |
1276 "kill", | 1261 "kill", |
1277 (PyCFunction)_mysql_ConnectionObject_kill, | 1262 (PyCFunction)_mysql_ConnectionObject_kill, |
1297 _mysql_ConnectionObject_select_db__doc__ | 1282 _mysql_ConnectionObject_select_db__doc__ |
1298 }, | 1283 }, |
1299 { | 1284 { |
1300 "shutdown", | 1285 "shutdown", |
1301 (PyCFunction)_mysql_ConnectionObject_shutdown, | 1286 (PyCFunction)_mysql_ConnectionObject_shutdown, |
1302 METH_VARARGS, | 1287 METH_NOARGS, |
1303 _mysql_ConnectionObject_shutdown__doc__ | 1288 _mysql_ConnectionObject_shutdown__doc__ |
1304 }, | 1289 }, |
1305 { | 1290 { |
1306 "stat", | 1291 "stat", |
1307 (PyCFunction)_mysql_ConnectionObject_stat, | 1292 (PyCFunction)_mysql_ConnectionObject_stat, |
1308 METH_VARARGS, | 1293 METH_NOARGS, |
1309 _mysql_ConnectionObject_stat__doc__ | 1294 _mysql_ConnectionObject_stat__doc__ |
1310 }, | 1295 }, |
1311 { | 1296 { |
1312 "store_result", | 1297 "store_result", |
1313 (PyCFunction)_mysql_ConnectionObject_store_result, | 1298 (PyCFunction)_mysql_ConnectionObject_store_result, |
1314 METH_VARARGS, | 1299 METH_NOARGS, |
1315 _mysql_ConnectionObject_store_result__doc__ | 1300 _mysql_ConnectionObject_store_result__doc__ |
1316 }, | 1301 }, |
1317 { | 1302 { |
1318 "string_literal", | 1303 "string_literal", |
1319 (PyCFunction)_mysql_string_literal, | 1304 (PyCFunction)_mysql_string_literal, |
1320 METH_VARARGS, | 1305 METH_VARARGS, |
1321 _mysql_string_literal__doc__}, | 1306 _mysql_string_literal__doc__}, |
1322 { | 1307 { |
1323 "thread_id", | 1308 "thread_id", |
1324 (PyCFunction)_mysql_ConnectionObject_thread_id, | 1309 (PyCFunction)_mysql_ConnectionObject_thread_id, |
1325 METH_VARARGS, | 1310 METH_NOARGS, |
1326 _mysql_ConnectionObject_thread_id__doc__ | 1311 _mysql_ConnectionObject_thread_id__doc__ |
1327 }, | 1312 }, |
1328 { | 1313 { |
1329 "use_result", | 1314 "use_result", |
1330 (PyCFunction)_mysql_ConnectionObject_use_result, | 1315 (PyCFunction)_mysql_ConnectionObject_use_result, |
1331 METH_VARARGS, | 1316 METH_NOARGS, |
1332 _mysql_ConnectionObject_use_result__doc__ | 1317 _mysql_ConnectionObject_use_result__doc__ |
1333 }, | 1318 }, |
1334 {NULL, NULL} /* sentinel */ | 1319 {NULL, NULL} /* sentinel */ |
1335 }; | 1320 }; |
1336 | 1321 |
1370 offsetof(_mysql_ConnectionObject,connection.client_flag), | 1355 offsetof(_mysql_ConnectionObject,connection.client_flag), |
1371 "Client flags; refer to MySQLdb.constants.CLIENT" | 1356 "Client flags; refer to MySQLdb.constants.CLIENT" |
1372 ), | 1357 ), |
1373 {NULL} /* Sentinel */ | 1358 {NULL} /* Sentinel */ |
1374 }; | 1359 }; |
1375 | 1360 |
1376 static PyObject * | 1361 static PyObject * |
1377 _mysql_ConnectionObject_getattr( | 1362 _mysql_ConnectionObject_getattr( |
1378 _mysql_ConnectionObject *self, | 1363 _mysql_ConnectionObject *self, |
1379 char *name) | 1364 char *name) |
1380 { | 1365 { |