[
  {
    "path": ".gitignore",
    "content": "*.pyc\n*.pyo\n*.o\n*.so\n*.pyd\n*.gz\n*.zip\n*.egg\n*.egg-info/\n.tox/\nbuild/\ndist/\n"
  },
  {
    "path": ".travis.yml",
    "content": "language: python\npython:\n - \"2.6\"\n - \"2.7\"\n - \"pypy\"\ninstall: python setup.py install\nbefore_script: mysql -e 'create database mysqldb_test charset utf8;'\nscript: TESTDB=travis.cnf nosetests\n"
  },
  {
    "path": "GPL-2.0",
    "content": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 2, June 1991\n\n Copyright (C) 1989, 1991 Free Software Foundation, Inc.,\n 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The licenses for most software are designed to take away your\nfreedom to share and change it.  By contrast, the GNU General Public\nLicense is intended to guarantee your freedom to share and change free\nsoftware--to make sure the software is free for all its users.  This\nGeneral Public License applies to most of the Free Software\nFoundation's software and to any other program whose authors commit to\nusing it.  (Some other Free Software Foundation software is covered by\nthe GNU Lesser General Public License instead.)  You can apply it to\nyour programs, too.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthis service if you wish), that you receive source code or can get it\nif you want it, that you can change the software or use pieces of it\nin new free programs; and that you know you can do these things.\n\n  To protect your rights, we need to make restrictions that forbid\nanyone to deny you these rights or to ask you to surrender the rights.\nThese restrictions translate to certain responsibilities for you if you\ndistribute copies of the software, or if you modify it.\n\n  For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must give the recipients all the rights that\nyou have.  You must make sure that they, too, receive or can get the\nsource code.  And you must show them these terms so they know their\nrights.\n\n  We protect your rights with two steps: (1) copyright the software, and\n(2) offer you this license which gives you legal permission to copy,\ndistribute and/or modify the software.\n\n  Also, for each author's protection and ours, we want to make certain\nthat everyone understands that there is no warranty for this free\nsoftware.  If the software is modified by someone else and passed on, we\nwant its recipients to know that what they have is not the original, so\nthat any problems introduced by others will not reflect on the original\nauthors' reputations.\n\n  Finally, any free program is threatened constantly by software\npatents.  We wish to avoid the danger that redistributors of a free\nprogram will individually obtain patent licenses, in effect making the\nprogram proprietary.  To prevent this, we have made it clear that any\npatent must be licensed for everyone's free use or not licensed at all.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                    GNU GENERAL PUBLIC LICENSE\n   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\n\n  0. This License applies to any program or other work which contains\na notice placed by the copyright holder saying it may be distributed\nunder the terms of this General Public License.  The \"Program\", below,\nrefers to any such program or work, and a \"work based on the Program\"\nmeans either the Program or any derivative work under copyright law:\nthat is to say, a work containing the Program or a portion of it,\neither verbatim or with modifications and/or translated into another\nlanguage.  (Hereinafter, translation is included without limitation in\nthe term \"modification\".)  Each licensee is addressed as \"you\".\n\nActivities other than copying, distribution and modification are not\ncovered by this License; they are outside its scope.  The act of\nrunning the Program is not restricted, and the output from the Program\nis covered only if its contents constitute a work based on the\nProgram (independent of having been made by running the Program).\nWhether that is true depends on what the Program does.\n\n  1. You may copy and distribute verbatim copies of the Program's\nsource code as you receive it, in any medium, provided that you\nconspicuously and appropriately publish on each copy an appropriate\ncopyright notice and disclaimer of warranty; keep intact all the\nnotices that refer to this License and to the absence of any warranty;\nand give any other recipients of the Program a copy of this License\nalong with the Program.\n\nYou may charge a fee for the physical act of transferring a copy, and\nyou may at your option offer warranty protection in exchange for a fee.\n\n  2. You may modify your copy or copies of the Program or any portion\nof it, thus forming a work based on the Program, and copy and\ndistribute such modifications or work under the terms of Section 1\nabove, provided that you also meet all of these conditions:\n\n    a) You must cause the modified files to carry prominent notices\n    stating that you changed the files and the date of any change.\n\n    b) You must cause any work that you distribute or publish, that in\n    whole or in part contains or is derived from the Program or any\n    part thereof, to be licensed as a whole at no charge to all third\n    parties under the terms of this License.\n\n    c) If the modified program normally reads commands interactively\n    when run, you must cause it, when started running for such\n    interactive use in the most ordinary way, to print or display an\n    announcement including an appropriate copyright notice and a\n    notice that there is no warranty (or else, saying that you provide\n    a warranty) and that users may redistribute the program under\n    these conditions, and telling the user how to view a copy of this\n    License.  (Exception: if the Program itself is interactive but\n    does not normally print such an announcement, your work based on\n    the Program is not required to print an announcement.)\n\nThese requirements apply to the modified work as a whole.  If\nidentifiable sections of that work are not derived from the Program,\nand can be reasonably considered independent and separate works in\nthemselves, then this License, and its terms, do not apply to those\nsections when you distribute them as separate works.  But when you\ndistribute the same sections as part of a whole which is a work based\non the Program, the distribution of the whole must be on the terms of\nthis License, whose permissions for other licensees extend to the\nentire whole, and thus to each and every part regardless of who wrote it.\n\nThus, it is not the intent of this section to claim rights or contest\nyour rights to work written entirely by you; rather, the intent is to\nexercise the right to control the distribution of derivative or\ncollective works based on the Program.\n\nIn addition, mere aggregation of another work not based on the Program\nwith the Program (or with a work based on the Program) on a volume of\na storage or distribution medium does not bring the other work under\nthe scope of this License.\n\n  3. You may copy and distribute the Program (or a work based on it,\nunder Section 2) in object code or executable form under the terms of\nSections 1 and 2 above provided that you also do one of the following:\n\n    a) Accompany it with the complete corresponding machine-readable\n    source code, which must be distributed under the terms of Sections\n    1 and 2 above on a medium customarily used for software interchange; or,\n\n    b) Accompany it with a written offer, valid for at least three\n    years, to give any third party, for a charge no more than your\n    cost of physically performing source distribution, a complete\n    machine-readable copy of the corresponding source code, to be\n    distributed under the terms of Sections 1 and 2 above on a medium\n    customarily used for software interchange; or,\n\n    c) Accompany it with the information you received as to the offer\n    to distribute corresponding source code.  (This alternative is\n    allowed only for noncommercial distribution and only if you\n    received the program in object code or executable form with such\n    an offer, in accord with Subsection b above.)\n\nThe source code for a work means the preferred form of the work for\nmaking modifications to it.  For an executable work, complete source\ncode means all the source code for all modules it contains, plus any\nassociated interface definition files, plus the scripts used to\ncontrol compilation and installation of the executable.  However, as a\nspecial exception, the source code distributed need not include\nanything that is normally distributed (in either source or binary\nform) with the major components (compiler, kernel, and so on) of the\noperating system on which the executable runs, unless that component\nitself accompanies the executable.\n\nIf distribution of executable or object code is made by offering\naccess to copy from a designated place, then offering equivalent\naccess to copy the source code from the same place counts as\ndistribution of the source code, even though third parties are not\ncompelled to copy the source along with the object code.\n\n  4. You may not copy, modify, sublicense, or distribute the Program\nexcept as expressly provided under this License.  Any attempt\notherwise to copy, modify, sublicense or distribute the Program is\nvoid, and will automatically terminate your rights under this License.\nHowever, parties who have received copies, or rights, from you under\nthis License will not have their licenses terminated so long as such\nparties remain in full compliance.\n\n  5. You are not required to accept this License, since you have not\nsigned it.  However, nothing else grants you permission to modify or\ndistribute the Program or its derivative works.  These actions are\nprohibited by law if you do not accept this License.  Therefore, by\nmodifying or distributing the Program (or any work based on the\nProgram), you indicate your acceptance of this License to do so, and\nall its terms and conditions for copying, distributing or modifying\nthe Program or works based on it.\n\n  6. Each time you redistribute the Program (or any work based on the\nProgram), the recipient automatically receives a license from the\noriginal licensor to copy, distribute or modify the Program subject to\nthese terms and conditions.  You may not impose any further\nrestrictions on the recipients' exercise of the rights granted herein.\nYou are not responsible for enforcing compliance by third parties to\nthis License.\n\n  7. If, as a consequence of a court judgment or allegation of patent\ninfringement or for any other reason (not limited to patent issues),\nconditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot\ndistribute so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you\nmay not distribute the Program at all.  For example, if a patent\nlicense would not permit royalty-free redistribution of the Program by\nall those who receive copies directly or indirectly through you, then\nthe only way you could satisfy both it and this License would be to\nrefrain entirely from distribution of the Program.\n\nIf any portion of this section is held invalid or unenforceable under\nany particular circumstance, the balance of the section is intended to\napply and the section as a whole is intended to apply in other\ncircumstances.\n\nIt is not the purpose of this section to induce you to infringe any\npatents or other property right claims or to contest validity of any\nsuch claims; this section has the sole purpose of protecting the\nintegrity of the free software distribution system, which is\nimplemented by public license practices.  Many people have made\ngenerous contributions to the wide range of software distributed\nthrough that system in reliance on consistent application of that\nsystem; it is up to the author/donor to decide if he or she is willing\nto distribute software through any other system and a licensee cannot\nimpose that choice.\n\nThis section is intended to make thoroughly clear what is believed to\nbe a consequence of the rest of this License.\n\n  8. If the distribution and/or use of the Program is restricted in\ncertain countries either by patents or by copyrighted interfaces, the\noriginal copyright holder who places the Program under this License\nmay add an explicit geographical distribution limitation excluding\nthose countries, so that distribution is permitted only in or among\ncountries not thus excluded.  In such case, this License incorporates\nthe limitation as if written in the body of this License.\n\n  9. The Free Software Foundation may publish revised and/or new versions\nof the General Public License from time to time.  Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\nEach version is given a distinguishing version number.  If the Program\nspecifies a version number of this License which applies to it and \"any\nlater version\", you have the option of following the terms and conditions\neither of that version or of any later version published by the Free\nSoftware Foundation.  If the Program does not specify a version number of\nthis License, you may choose any version ever published by the Free Software\nFoundation.\n\n  10. If you wish to incorporate parts of the Program into other free\nprograms whose distribution conditions are different, write to the author\nto ask for permission.  For software which is copyrighted by the Free\nSoftware Foundation, write to the Free Software Foundation; we sometimes\nmake exceptions for this.  Our decision will be guided by the two goals\nof preserving the free status of all derivatives of our free software and\nof promoting the sharing and reuse of software generally.\n\n                            NO WARRANTY\n\n  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY\nFOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN\nOTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES\nPROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED\nOR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS\nTO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE\nPROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,\nREPAIR OR CORRECTION.\n\n  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR\nREDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,\nINCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING\nOUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED\nTO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY\nYOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER\nPROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE\nPOSSIBILITY OF SUCH DAMAGES.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nconvey the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This program is free software; you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation; either version 2 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License along\n    with this program; if not, write to the Free Software Foundation, Inc.,\n    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n\nAlso add information on how to contact you by electronic and paper mail.\n\nIf the program is interactive, make it output a short notice like this\nwhen it starts in an interactive mode:\n\n    Gnomovision version 69, Copyright (C) year name of author\n    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n    This is free software, and you are welcome to redistribute it\n    under certain conditions; type `show c' for details.\n\nThe hypothetical commands `show w' and `show c' should show the appropriate\nparts of the General Public License.  Of course, the commands you use may\nbe called something other than `show w' and `show c'; they could even be\nmouse-clicks or menu items--whatever suits your program.\n\nYou should also get your employer (if you work as a programmer) or your\nschool, if any, to sign a \"copyright disclaimer\" for the program, if\nnecessary.  Here is a sample; alter the names:\n\n  Yoyodyne, Inc., hereby disclaims all copyright interest in the program\n  `Gnomovision' (which makes passes at compilers) written by James Hacker.\n\n  <signature of Ty Coon>, 1 April 1989\n  Ty Coon, President of Vice\n\nThis General Public License does not permit incorporating your program into\nproprietary programs.  If your program is a subroutine library, you may\nconsider it more useful to permit linking proprietary applications with the\nlibrary.  If this is what you want to do, use the GNU Lesser General\nPublic License instead of this License.\n"
  },
  {
    "path": "HISTORY",
    "content": "=====================\r\n What's new in 1.2.4\r\n=====================\r\n\r\nfinal\r\n=====\r\n\r\nNo changes.\r\n\r\n\r\nrc 1\r\n====\r\n\r\nFixed a dangling reference to the old types module.\r\n\r\n\r\nbeta 5\r\n======\r\n\r\nAnother internal fix for handling remapped character sets.\r\n\r\n_mysql.c was broken for the case where read_timeout was *not* available. (Issue #6)\r\n\r\nDocumentation was converted to sphinx but there is a lot of cleanup left to do.\r\n\r\n\r\nbeta 4\r\n======\r\n\r\nAdded support for the MySQL read_timeout option. Contributed by\r\nJean Schurger (jean@schurger.org).\r\n\r\nAdded a workaround so that the MySQL character set utf8mb4 works with Python; utf8 is substituted\r\non the Python side.\r\n\r\n\r\nbeta 3\r\n======\r\n\r\nUnified test database configuration, and set up CI testing with Travis.\r\n\r\nApplied several patches from André Malo (ndparker@users.sf.net) which fix some issues\r\nwith exception handling and reference counting and TEXT/BLOB conversion.\r\n\r\n\r\nbeta 2\r\n======\r\n\r\nReverted an accidental change in the exception format. (issue #1)\r\n\r\nReverted some raise statements so that they will continue to work with Python < 2.6\r\n\r\n\r\nbeta 1\r\n======\r\n\r\nA lot of work has been done towards Python 3 compatibility, and avoiding warnings with Python 2.7.\r\nThis includes import changes, converting dict.has_kay(k) to k in dict, updating some test suite methods, etc.\r\n\r\nDue to the difficulties of supporting Python 3 and Python < 2.7, 1.2.4 will support Python 2.4 though 2.7.\r\n1.3.0 will support Python 3 and Python 2.7 and 2.6.\r\n\r\nMySQLdb-2.0 is instead going to become moist-1.0. See https://github.com/farcepest/moist\r\n\r\nThe Windows build has been simplified, and I plan to correct pre-built i386 packages built\r\nagainst the python.org Python-2.7 package and MySQL Connector/C-6.0. Contact me if you\r\nneed ia64 packages.\r\n\r\nThe connection's cursorclass (if not default) was being lost on reconnect.\r\n\r\nNewer versions of MySQL don't use OpenSSL and therefore don't have HAVE_SSL defined, but they do have\r\na different SSL library. Fixed this so SSL support would be enabled in this case.\r\n\r\nThe regex that looked for SQL INSERT statement and VALUES in cursor.executemany() was made case-insensitive\r\nagain.\r\n\r\n\r\n=====================\r\n What's new in 1.2.3\r\n=====================\r\n\r\nez_setup.py has been update to include various fixes that affect the build.\r\n\r\nBetter Python version and dependency detection as well as eliminate exception\r\nwarnings under Python 2.6.\r\n\r\nEliminated memory leaks related to Unicode and failed connections.\r\n\r\nCorrected connection .escape() functionality.\r\n\r\nMiscellaneous cleanups and and expanded testing suite to ensure ongoing release\r\nquality.\r\n\r\n=====================\r\n What's new in 1.2.2\r\n=====================\r\n\r\nThe build system has been completely redone and should now build\r\non Windows without any patching; uses setuptools.\r\n\r\nAdded compatibility for Python 2.5, including support for with statement.\r\n\r\nconnection.ping() now takes an optional boolean argument which can\r\nenable (or disable) automatic reconnection.\r\n\r\nSupport returning SET columns as Python sets was removed due to an\r\nAPI bug in MySQL; corresponding test removed.\r\n\r\nAdded a test for single-character CHAR columns.\r\n\r\nBLOB columns are now returned as Python strings instead of byte arrays.\r\n\r\nBINARY character columns are always returned as Python strings, and not\r\nunicode.\r\n\r\nFixed a bug introduced in 1.2.1 where the new SHOW WARNINGS support broke\r\nSSCursor.\r\n\r\nOnly encode the query (convert to a string) when it is a unicode instance;\r\nre-encoding encoded strings would break things.\r\n\r\nMake a deep copy of conv when connecting, since it can be modified.\r\n\r\nAdded support for new VARCHAR and BIT column types.\r\n\r\nDBAPISet objects were broken, but nobody noticed.\r\n\r\n\r\n========================\r\n What's new in 1.2.1_p2\r\n========================\r\n\r\nThere are some minor build fixes which probably only affect MySQL\r\nolder than 4.0.\r\n\r\nIf you had MySQL older than 4.1, the new charset and sql_mode\r\nparameters didn't work right. In fact, it was impossible to create\r\na connection due to the charset problem.\r\n\r\nIf you are using MySQL-4.1 or newer, there is no practical difference\r\nbetween 1.2.1 and 1.2.1_p2, and you don't need to upgrade.\r\n\r\n\r\n=====================\r\n What's new in 1.2.1\r\n=====================\r\n\r\nSwitched to Subversion. Was going to do this for 1.3, but a\r\nSourceForge CVS outage has forced the issue.\r\n\r\nMapped a lot of new 4.1 and 5.0 error codes to Python exceptions\r\n\r\nAdded an API call for mysql_set_character_set(charset) (MySQL > 5.0.7)\r\n\r\nAdded an API call for mysql_get_character_set_info() (MySQL > 5.0.10)\r\n\r\nRevamped the build system. Edit site.cfg if necessary (probably not\r\nin most cases)\r\n\r\nPython-2.3 is now the minimum version.\r\n\r\nDropped support for mx.Datetime and stringtimes; always uses Python\r\ndatetime module now.\r\n\r\nImproved unit tests\r\n\r\nNew connect() options:\r\n* charset: sets character set, implies use_unicode\r\n* sql_mode: sets SQL mode (i.e. ANSI, etc.; see MySQL docs)\r\n\r\nWhen using MySQL-4.1 or newer, enables MULTI_STATEMENTS\r\n\r\nWhen using MySQL-5.0 or newer, enables MULTI_RESULTS\r\n\r\nWhen using MySQL-4.1 or newer, more detailed warning messages\r\nare produced\r\n\r\nSET columns returned as Python Set types; you can pass a Set as\r\na parameter to cursor.execute().\r\n\r\nSupport for the new MySQL-5.0 DECIMAL implementation\r\n\r\nSupport for Python Decimal type\r\n\r\nSome use of weak references internally. Cursors no longer leak\r\nif you don't close them. Connections still do, unfortunately.\r\n\r\nursor.fetchXXXDict() methods raise DeprecationWarning\r\n\r\ncursor.begin() is making a brief reappearence.\r\n\r\ncursor.callproc() now works, with some limitations.\r\n\r\n"
  },
  {
    "path": "INSTALL",
    "content": "====================\nMySQLdb Installation\n====================\n\n.. contents::\n..\n\nPrerequisites\n-------------\n\n+ Python 2.3.4 or higher\n\n  * http://www.python.org/\n\n  * Versions lower than 2.3 WON'T WORK.\n\n  * 2.4 is the primary test environment.\n\n  * Red Hat Linux:\n\n    - Make sure you have the Python development headers and libraries\n      (python-devel).\n\n+ setuptools\n\n  * http://pypi.python.org/pypi/setuptools\n\n+ MySQL 3.23.32 or higher\n\n  * http://www.mysql.com/downloads/\n\n  * Versions lower than 3.22 definitely WON'T WORK.\n\n  * Versions lower than 3.22.19 might not work.\n\n  * MySQL-3.22 might work but isn't supported anymore. It's very old.\n\n  * MySQL-3.23 ought to work, but it's pretty elderly.\n\n  * MySQL-4.0 is supported, but not tested and slightly discouraged.\n\n  * MySQL-4.1 is supported. The prepared statements API is not\n    supported, and won't be until MySQLdb-1.3 or 2.0, if ever.\n\n  * MySQL-5.0 is supported and tested, including stored procedures.\n\n  * MySQL-5.1 is supported (currently a release candidate) but untested.\n    It should work.\n\n  * MySQL-6.0 is sorta-kinda-supported (currently alpha) but untested.\n    It should work.\n\n  * Drizzle <https://launchpad.net/drizzle> is a fork of MySQL. So far\n    the C API looks really similar except everything is renamed.\n    Drizzle support probably won't happen in 1.2. There may be have to\n    be an entirely different module, but still using DB-API.\n\n  * MaxDB, formerly known as SAP DB (and maybe Adabas D?), is a\n    completely different animal. Use the sapdb.sql module that comes\n    with MaxDB.\n\n  * Red Hat Linux packages:\n\n    - mysql-devel to compile\n\n    - mysql and/or mysql-devel to run\n\n  * MySQL.com RPM packages:\n\n    - MySQL-devel to compile\n\n    - MySQL-shared if you want to use their shared\n      library. Otherwise you'll get a statically-linked module,\n      which may or may not be what you want.\n\n    - MySQL-shared to run if you compiled with MySQL-shared installed\n\n  * Transactions (particularly InnoDB tables) are supported for\n    MySQL-3.23 and up. You may need a special package from your vendor\n    with this support turned on.\n\n+  zlib\n\n   * Required for MySQL-3.23 and newer.\n\n   * Red Hat Linux\n\n     - zlib-devel to compile\n\n     - zlib to run\n\n+ openssl\n\n  * May be needed for MySQL-4.0 or newer, depending on compilation\n    options. If you need it, you probably already have it.\n\n    - you may need openssl-devel on some platforms\n\n+ C compiler\n\n  * Most free software-based systems already have this, usually gcc.\n\n  * Most commercial UNIX platforms also come with a C compiler, or\n    you can also use gcc.\n\n  * If you have some Windows flavor, you usually have to pay extra\n    for this, or you can use Cygwin_.\n\n.. _Cygwin: http://www.cygwin.com/\n\n\nBuilding and installing\n-----------------------\n\nThe setup.py script uses mysql_config to find all compiler and linker\noptions, and should work as is on any POSIX-like platform, so long as\nmysql_config is in your path.\n\nDepending on which version of MySQL you have, you may have the option\nof using three different client libraries. To select the client library,\nedit the [options] section of site.cfg:\n\n    embedded\n        use embedded server library (libmysqld) if True; otherwise use\n\tone of the client libraries (default).\n\n    threadsafe\n        thread-safe client library (libmysqlclient_r) if True (default);\n\totherwise use non-thread-safe (libmysqlclient). You should\n\talways use the thread-safe library if you have the option;\n\totherwise you *may* have problems.\n\n    static\n        if True, try to link against a static library; otherwise link\n\tagainst dynamic libraries (default). You may need static linking\n\tto use the embedded server.\n\n\nFinally, putting it together::\n\n  $ tar xfz MySQL-python-1.2.1.tar.gz\n  $ cd MySQL-python-1.2.1\n  $ # edit site.cfg if necessary\n  $ python setup.py build\n  $ sudo python setup.py install # or su first\n\n\nWindows\n.......\n\nI don't do Windows. However if someone provides me with a package for\nWindows, I'll make it available. Don't ask me for help with Windows\nbecause I can't help you.\n\nGenerally, though, running setup.py is similar to above::\n\n  C:\\...> python setup.py install\n  C:\\...> python setup.py bdist_wininst\n\nThe latter example should build a Windows installer package, if you\nhave the correct tools. In any event, you *must* have a C compiler.\nAdditionally, you have to set an environment variable (mysqlroot)\nwhich is the path to your MySQL installation. In theory, it would be\npossible to get this information out of the registry, but like I said,\nI don't do Windows, but I'll accept a patch that does this.\n\nOn Windows, you will definitely have to edit site.cfg since there is\nno mysql_config in the MySQL package.\n\n\nZope\n....\n\nIf you are using a binary package of Zope, you need run setup.py with\nthe python executable that came with Zope. Otherwise, you'll install\ninto the wrong Python tree and Zope (ZMySQLDA) will not be able to\nfind _mysql.\n\n\nBinary Packages\n---------------\n\nI don't plan to make binary packages any more. However, if someone\ncontributes one, I will make it available. Several OS vendors have\ntheir own packages available.\n\n\nRPMs\n....\n\nIf you prefer to install RPMs, you can use the bdist_rpm command with\nsetup.py. This only builds the RPM; it does not install it. You may\nwant to use the --python=XXX option, where XXX is the name of the\nPython executable, i.e. python, python2, python2.4; the default is\npython. Using this will incorporate the Python executable name into\nthe package name for the RPM so you have install the package multiple\ntimes if you need to support more than one version of Python. You can\nalso set this in setup.cfg.\n\n\nRed Hat Linux\n.............\n\nMySQL-python is pre-packaged in Red Hat Linux 7.x and newer. This\nincludes Fedora Core and Red Hat Enterprise Linux. You can also\nbuild your own RPM packages as described above.\n\n\nDebian GNU/Linux\n................\n\nPackaged as `python-mysqldb`_::\n\n\t# apt-get install python-mysqldb\n\nOr use Synaptic.\n\n.. _`python-mysqldb`: http://packages.debian.org/python-mysqldb\n\n\nUbuntu\n......\n\nSame as with Debian.\n\n\nGentoo Linux\n............\n\nPackaged as `mysql-python`_. ::\n\n      # emerge sync\n      # emerge mysql-python\n      # emerge zmysqlda # if you use Zope\n\n.. _`mysql-python`: http://packages.gentoo.org/search/?sstring=mysql-python\n\n\nBSD\n...\n\nMySQL-python is a ported package in FreeBSD, NetBSD, and OpenBSD,\nalthough the name may vary to match OS conventions.\n\n\nLicense\n-------\n\nGPL or the original license based on Python 1.5.2's license.\n\n\n:Author: Andy Dustman <andy@dustman.net>\n:Revision: $Id$\n"
  },
  {
    "path": "MANIFEST.in",
    "content": "recursive-include doc *.rst\r\nrecursive-include tests *.py\r\ninclude doc/conf.py\r\ninclude MANIFEST.in\r\ninclude HISTORY\r\ninclude INSTALL\r\ninclude README.md\r\ninclude GPL-2.0\r\ninclude pymemcompat.h\r\ninclude metadata.cfg\r\ninclude site.cfg\r\ninclude setup_common.py\r\ninclude setup_posix.py\r\ninclude setup_windows.py\r\n"
  },
  {
    "path": "MySQLdb/__init__.py",
    "content": "\"\"\"MySQLdb - A DB API v2.0 compatible interface to MySQL.\n\nThis package is a wrapper around _mysql, which mostly implements the\nMySQL C API.\n\nconnect() -- connects to server\n\nSee the C API specification and the MySQL documentation for more info\non other items.\n\nFor information on how MySQLdb handles type conversion, see the\nMySQLdb.converters module.\n\n\"\"\"\n\n__revision__ = \"\"\"$Revision$\"\"\"[11:-2]\nfrom MySQLdb.release import __version__, version_info, __author__\n\nimport _mysql\n\nif version_info != _mysql.version_info:\n    raise ImportError(\"this is MySQLdb version %s, but _mysql is version %r\" %\n                      (version_info, _mysql.version_info))\n\nthreadsafety = 1\napilevel = \"2.0\"\nparamstyle = \"format\"\n\nfrom _mysql import *\nfrom MySQLdb.constants import FIELD_TYPE\nfrom MySQLdb.times import Date, Time, Timestamp, \\\n    DateFromTicks, TimeFromTicks, TimestampFromTicks\n\ntry:\n    frozenset\nexcept NameError:\n    from sets import ImmutableSet as frozenset\n\nclass DBAPISet(frozenset):\n\n    \"\"\"A special type of set for which A == x is true if A is a\n    DBAPISet and x is a member of that set.\"\"\"\n\n    def __eq__(self, other):\n        if isinstance(other, DBAPISet):\n            return not self.difference(other)\n        return other in self\n\n\nSTRING    = DBAPISet([FIELD_TYPE.ENUM, FIELD_TYPE.STRING,\n                     FIELD_TYPE.VAR_STRING])\nBINARY    = DBAPISet([FIELD_TYPE.BLOB, FIELD_TYPE.LONG_BLOB,\n                     FIELD_TYPE.MEDIUM_BLOB, FIELD_TYPE.TINY_BLOB])\nNUMBER    = DBAPISet([FIELD_TYPE.DECIMAL, FIELD_TYPE.DOUBLE, FIELD_TYPE.FLOAT,\n                     FIELD_TYPE.INT24, FIELD_TYPE.LONG, FIELD_TYPE.LONGLONG,\n                     FIELD_TYPE.TINY, FIELD_TYPE.YEAR])\nDATE      = DBAPISet([FIELD_TYPE.DATE, FIELD_TYPE.NEWDATE])\nTIME      = DBAPISet([FIELD_TYPE.TIME])\nTIMESTAMP = DBAPISet([FIELD_TYPE.TIMESTAMP, FIELD_TYPE.DATETIME])\nDATETIME  = TIMESTAMP\nROWID     = DBAPISet()\n\ndef test_DBAPISet_set_equality():\n    assert STRING == STRING\n\ndef test_DBAPISet_set_inequality():\n    assert STRING != NUMBER\n\ndef test_DBAPISet_set_equality_membership():\n    assert FIELD_TYPE.VAR_STRING == STRING\n\ndef test_DBAPISet_set_inequality_membership():\n    assert FIELD_TYPE.DATE != STRING\n\ndef Binary(x):\n    return str(x)\n\ndef Connect(*args, **kwargs):\n    \"\"\"Factory function for connections.Connection.\"\"\"\n    from MySQLdb.connections import Connection\n    return Connection(*args, **kwargs)\n\nconnect = Connection = Connect\n\n__all__ = [ 'BINARY', 'Binary', 'Connect', 'Connection', 'DATE',\n    'Date', 'Time', 'Timestamp', 'DateFromTicks', 'TimeFromTicks',\n    'TimestampFromTicks', 'DataError', 'DatabaseError', 'Error',\n    'FIELD_TYPE', 'IntegrityError', 'InterfaceError', 'InternalError',\n    'MySQLError', 'NULL', 'NUMBER', 'NotSupportedError', 'DBAPISet',\n    'OperationalError', 'ProgrammingError', 'ROWID', 'STRING', 'TIME',\n    'TIMESTAMP', 'Warning', 'apilevel', 'connect', 'connections',\n    'constants', 'converters', 'cursors', 'debug', 'escape', 'escape_dict',\n    'escape_sequence', 'escape_string', 'get_client_info',\n    'paramstyle', 'string_literal', 'threadsafety', 'version_info']\n\n\n\n\n"
  },
  {
    "path": "MySQLdb/connections.py",
    "content": "\"\"\"\n\nThis module implements connections for MySQLdb. Presently there is\nonly one class: Connection. Others are unlikely. However, you might\nwant to make your own subclasses. In most cases, you will probably\noverride Connection.default_cursor with a non-standard Cursor class.\n\n\"\"\"\nfrom MySQLdb import cursors\nfrom _mysql_exceptions import Warning, Error, InterfaceError, DataError, \\\n     DatabaseError, OperationalError, IntegrityError, InternalError, \\\n     NotSupportedError, ProgrammingError\nimport types, _mysql\nimport re\n\n\ndef defaulterrorhandler(connection, cursor, errorclass, errorvalue):\n    \"\"\"\n\n    If cursor is not None, (errorclass, errorvalue) is appended to\n    cursor.messages; otherwise it is appended to\n    connection.messages. Then errorclass is raised with errorvalue as\n    the value.\n\n    You can override this with your own error handler by assigning it\n    to the instance.\n\n    \"\"\"\n    error = errorclass, errorvalue\n    if cursor:\n        cursor.messages.append(error)\n    else:\n        connection.messages.append(error)\n    del cursor\n    del connection\n    raise errorclass, errorvalue\n\nre_numeric_part = re.compile(r\"^(\\d+)\")\n\ndef numeric_part(s):\n    \"\"\"Returns the leading numeric part of a string.\n\n    >>> numeric_part(\"20-alpha\")\n    20\n    >>> numeric_part(\"foo\")\n    >>> numeric_part(\"16b\")\n    16\n    \"\"\"\n\n    m = re_numeric_part.match(s)\n    if m:\n        return int(m.group(1))\n    return None\n\n\nclass Connection(_mysql.connection):\n\n    \"\"\"MySQL Database Connection Object\"\"\"\n\n    default_cursor = cursors.Cursor\n\n    def __init__(self, *args, **kwargs):\n        \"\"\"\n\n        Create a connection to the database. It is strongly recommended\n        that you only use keyword parameters. Consult the MySQL C API\n        documentation for more information.\n\n        host\n          string, host to connect\n\n        user\n          string, user to connect as\n\n        passwd\n          string, password to use\n\n        db\n          string, database to use\n\n        port\n          integer, TCP/IP port to connect to\n\n        unix_socket\n          string, location of unix_socket to use\n\n        conv\n          conversion dictionary, see MySQLdb.converters\n\n        connect_timeout\n          number of seconds to wait before the connection attempt\n          fails.\n\n        compress\n          if set, compression is enabled\n\n        named_pipe\n          if set, a named pipe is used to connect (Windows only)\n\n        init_command\n          command which is run once the connection is created\n\n        read_default_file\n          file from which default client values are read\n\n        read_default_group\n          configuration group to use from the default file\n\n        cursorclass\n          class object, used to create cursors (keyword only)\n\n        use_unicode\n          If True, text-like columns are returned as unicode objects\n          using the connection's character set.  Otherwise, text-like\n          columns are returned as strings.  columns are returned as\n          normal strings. Unicode objects will always be encoded to\n          the connection's character set regardless of this setting.\n\n        charset\n          If supplied, the connection character set will be changed\n          to this character set (MySQL-4.1 and newer). This implies\n          use_unicode=True.\n\n        sql_mode\n          If supplied, the session SQL mode will be changed to this\n          setting (MySQL-4.1 and newer). For more details and legal\n          values, see the MySQL documentation.\n\n        client_flag\n          integer, flags to use or 0\n          (see MySQL docs or constants/CLIENTS.py)\n\n        ssl\n          dictionary or mapping, contains SSL connection parameters;\n          see the MySQL documentation for more details\n          (mysql_ssl_set()).  If this is set, and the client does not\n          support SSL, NotSupportedError will be raised.\n\n        local_infile\n          integer, non-zero enables LOAD LOCAL INFILE; zero disables\n\n        autocommit\n          If False (default), autocommit is disabled.\n          If True, autocommit is enabled.\n          If None, autocommit isn't set and server default is used.\n\n        There are a number of undocumented, non-standard methods. See the\n        documentation for the MySQL C API for some hints on what they do.\n\n        \"\"\"\n        from MySQLdb.constants import CLIENT, FIELD_TYPE\n        from MySQLdb.converters import conversions\n        from weakref import proxy\n\n        kwargs2 = kwargs.copy()\n\n        if 'conv' in kwargs:\n            conv = kwargs['conv']\n        else:\n            conv = conversions\n\n        conv2 = {}\n        for k, v in conv.items():\n            if isinstance(k, int) and isinstance(v, list):\n                conv2[k] = v[:]\n            else:\n                conv2[k] = v\n        kwargs2['conv'] = conv2\n\n        cursorclass = kwargs2.pop('cursorclass', self.default_cursor)\n        charset = kwargs2.pop('charset', '')\n\n        if charset:\n            use_unicode = True\n        else:\n            use_unicode = False\n\n        use_unicode = kwargs2.pop('use_unicode', use_unicode)\n        sql_mode = kwargs2.pop('sql_mode', '')\n\n        client_flag = kwargs.get('client_flag', 0)\n        client_version = tuple([ numeric_part(n) for n in _mysql.get_client_info().split('.')[:2] ])\n        if client_version >= (4, 1):\n            client_flag |= CLIENT.MULTI_STATEMENTS\n        if client_version >= (5, 0):\n            client_flag |= CLIENT.MULTI_RESULTS\n\n        kwargs2['client_flag'] = client_flag\n\n        # PEP-249 requires autocommit to be initially off\n        autocommit = kwargs2.pop('autocommit', False)\n\n        super(Connection, self).__init__(*args, **kwargs2)\n        self.cursorclass = cursorclass\n        self.encoders = dict([ (k, v) for k, v in conv.items()\n                               if type(k) is not int ])\n\n        self._server_version = tuple([ numeric_part(n) for n in self.get_server_info().split('.')[:2] ])\n\n        db = proxy(self)\n        def _get_string_literal():\n            def string_literal(obj, dummy=None):\n                return db.string_literal(obj)\n            return string_literal\n\n        def _get_unicode_literal():\n            def unicode_literal(u, dummy=None):\n                return db.literal(u.encode(unicode_literal.charset))\n            return unicode_literal\n\n        def _get_string_decoder():\n            def string_decoder(s):\n                return s.decode(string_decoder.charset)\n            return string_decoder\n\n        string_literal = _get_string_literal()\n        self.unicode_literal = unicode_literal = _get_unicode_literal()\n        self.string_decoder = string_decoder = _get_string_decoder()\n        if not charset:\n            charset = self.character_set_name()\n        self.set_character_set(charset)\n\n        if sql_mode:\n            self.set_sql_mode(sql_mode)\n\n        if use_unicode:\n            self.converter[FIELD_TYPE.STRING].append((None, string_decoder))\n            self.converter[FIELD_TYPE.VAR_STRING].append((None, string_decoder))\n            self.converter[FIELD_TYPE.VARCHAR].append((None, string_decoder))\n            self.converter[FIELD_TYPE.BLOB].append((None, string_decoder))\n\n        self.encoders[types.StringType] = string_literal\n        self.encoders[types.UnicodeType] = unicode_literal\n        self._transactional = self.server_capabilities & CLIENT.TRANSACTIONS\n        if self._transactional:\n            if autocommit is not None:\n                self.autocommit(autocommit)\n        self.messages = []\n\n    def autocommit(self, on):\n        on = bool(on)\n        if self.get_autocommit() != on:\n            _mysql.connection.autocommit(self, on)\n\n    def cursor(self, cursorclass=None):\n        \"\"\"\n\n        Create a cursor on which queries may be performed. The\n        optional cursorclass parameter is used to create the\n        Cursor. By default, self.cursorclass=cursors.Cursor is\n        used.\n\n        \"\"\"\n        return (cursorclass or self.cursorclass)(self)\n\n    def __enter__(self):\n        if self.get_autocommit():\n            self.query(\"BEGIN\")\n        return self.cursor()\n\n    def __exit__(self, exc, value, tb):\n        if exc:\n            self.rollback()\n        else:\n            self.commit()\n\n    def literal(self, o):\n        \"\"\"\n\n        If o is a single object, returns an SQL literal as a string.\n        If o is a non-string sequence, the items of the sequence are\n        converted and returned as a sequence.\n\n        Non-standard. For internal use; do not use this in your\n        applications.\n\n        \"\"\"\n        return self.escape(o, self.encoders)\n\n    def begin(self):\n        \"\"\"Explicitly begin a connection. Non-standard.\n        DEPRECATED: Will be removed in 1.3.\n        Use an SQL BEGIN statement instead.\"\"\"\n        from warnings import warn\n        warn(\"begin() is non-standard and will be removed in 1.3\",\n             DeprecationWarning, 2)\n        self.query(\"BEGIN\")\n\n    if not hasattr(_mysql.connection, 'warning_count'):\n\n        def warning_count(self):\n            \"\"\"Return the number of warnings generated from the\n            last query. This is derived from the info() method.\"\"\"\n            from string import atoi\n            info = self.info()\n            if info:\n                return atoi(info.split()[-1])\n            else:\n                return 0\n\n    def set_character_set(self, charset):\n        \"\"\"Set the connection character set to charset. The character\n        set can only be changed in MySQL-4.1 and newer. If you try\n        to change the character set from the current value in an\n        older version, NotSupportedError will be raised.\"\"\"\n        if charset == \"utf8mb4\":\n            py_charset = \"utf8\"\n        else:\n            py_charset = charset\n        if self.character_set_name() != charset:\n            try:\n                super(Connection, self).set_character_set(charset)\n            except AttributeError:\n                if self._server_version < (4, 1):\n                    raise NotSupportedError(\"server is too old to set charset\")\n                self.query('SET NAMES %s' % charset)\n                self.store_result()\n        self.string_decoder.charset = py_charset\n        self.unicode_literal.charset = py_charset\n\n    def set_sql_mode(self, sql_mode):\n        \"\"\"Set the connection sql_mode. See MySQL documentation for\n        legal values.\"\"\"\n        if self._server_version < (4, 1):\n            raise NotSupportedError(\"server is too old to set sql_mode\")\n        self.query(\"SET SESSION sql_mode='%s'\" % sql_mode)\n        self.store_result()\n\n    def show_warnings(self):\n        \"\"\"Return detailed information about warnings as a\n        sequence of tuples of (Level, Code, Message). This\n        is only supported in MySQL-4.1 and up. If your server\n        is an earlier version, an empty sequence is returned.\"\"\"\n        if self._server_version < (4,1): return ()\n        self.query(\"SHOW WARNINGS\")\n        r = self.store_result()\n        warnings = r.fetch_row(0)\n        return warnings\n\n    Warning = Warning\n    Error = Error\n    InterfaceError = InterfaceError\n    DatabaseError = DatabaseError\n    DataError = DataError\n    OperationalError = OperationalError\n    IntegrityError = IntegrityError\n    InternalError = InternalError\n    ProgrammingError = ProgrammingError\n    NotSupportedError = NotSupportedError\n\n    errorhandler = defaulterrorhandler\n"
  },
  {
    "path": "MySQLdb/constants/CLIENT.py",
    "content": "\"\"\"MySQL CLIENT constants\n\nThese constants are used when creating the connection. Use bitwise-OR\n(|) to combine options together, and pass them as the client_flags\nparameter to MySQLdb.Connection. For more information on these flags,\nsee the MySQL C API documentation for mysql_real_connect().\n\n\"\"\"\n\nLONG_PASSWORD = 1\nFOUND_ROWS = 2\nLONG_FLAG = 4\nCONNECT_WITH_DB = 8\nNO_SCHEMA = 16\nCOMPRESS = 32\nODBC = 64\nLOCAL_FILES = 128\nIGNORE_SPACE = 256\nCHANGE_USER = 512\nINTERACTIVE = 1024\nSSL = 2048\nIGNORE_SIGPIPE = 4096\nTRANSACTIONS = 8192 # mysql_com.h was WRONG prior to 3.23.35\nRESERVED = 16384\nSECURE_CONNECTION = 32768\nMULTI_STATEMENTS = 65536\nMULTI_RESULTS = 131072\n\n\n"
  },
  {
    "path": "MySQLdb/constants/CR.py",
    "content": "\"\"\"MySQL Connection Errors\n\nNearly all of these raise OperationalError. COMMANDS_OUT_OF_SYNC\nraises ProgrammingError.\n\n\"\"\"\n\nMIN_ERROR = 2000\nMAX_ERROR = 2999\nUNKNOWN_ERROR = 2000\nSOCKET_CREATE_ERROR = 2001\nCONNECTION_ERROR = 2002\nCONN_HOST_ERROR = 2003\nIPSOCK_ERROR = 2004\nUNKNOWN_HOST = 2005\nSERVER_GONE_ERROR = 2006\nVERSION_ERROR = 2007\nOUT_OF_MEMORY = 2008\nWRONG_HOST_INFO = 2009\nLOCALHOST_CONNECTION = 2010\nTCP_CONNECTION = 2011\nSERVER_HANDSHAKE_ERR = 2012\nSERVER_LOST = 2013\nCOMMANDS_OUT_OF_SYNC = 2014\nNAMEDPIPE_CONNECTION = 2015\nNAMEDPIPEWAIT_ERROR = 2016\nNAMEDPIPEOPEN_ERROR = 2017\nNAMEDPIPESETSTATE_ERROR = 2018\nCANT_READ_CHARSET = 2019\nNET_PACKET_TOO_LARGE = 2020\n"
  },
  {
    "path": "MySQLdb/constants/ER.py",
    "content": "\"\"\"MySQL ER Constants\n\nThese constants are error codes for the bulk of the error conditions\nthat may occur.\n\n\"\"\"\n\nHASHCHK = 1000\nNISAMCHK = 1001\nNO = 1002\nYES = 1003\nCANT_CREATE_FILE = 1004\nCANT_CREATE_TABLE = 1005\nCANT_CREATE_DB = 1006\nDB_CREATE_EXISTS = 1007\nDB_DROP_EXISTS = 1008\nDB_DROP_DELETE = 1009\nDB_DROP_RMDIR = 1010\nCANT_DELETE_FILE = 1011\nCANT_FIND_SYSTEM_REC = 1012\nCANT_GET_STAT = 1013\nCANT_GET_WD = 1014\nCANT_LOCK = 1015\nCANT_OPEN_FILE = 1016\nFILE_NOT_FOUND = 1017\nCANT_READ_DIR = 1018\nCANT_SET_WD = 1019\nCHECKREAD = 1020\nDISK_FULL = 1021\nDUP_KEY = 1022\nERROR_ON_CLOSE = 1023\nERROR_ON_READ = 1024\nERROR_ON_RENAME = 1025\nERROR_ON_WRITE = 1026\nFILE_USED = 1027\nFILSORT_ABORT = 1028\nFORM_NOT_FOUND = 1029\nGET_ERRNO = 1030\nILLEGAL_HA = 1031\nKEY_NOT_FOUND = 1032\nNOT_FORM_FILE = 1033\nNOT_KEYFILE = 1034\nOLD_KEYFILE = 1035\nOPEN_AS_READONLY = 1036\nOUTOFMEMORY = 1037\nOUT_OF_SORTMEMORY = 1038\nUNEXPECTED_EOF = 1039\nCON_COUNT_ERROR = 1040\nOUT_OF_RESOURCES = 1041\nBAD_HOST_ERROR = 1042\nHANDSHAKE_ERROR = 1043\nDBACCESS_DENIED_ERROR = 1044\nACCESS_DENIED_ERROR = 1045\nNO_DB_ERROR = 1046\nUNKNOWN_COM_ERROR = 1047\nBAD_NULL_ERROR = 1048\nBAD_DB_ERROR = 1049\nTABLE_EXISTS_ERROR = 1050\nBAD_TABLE_ERROR = 1051\nNON_UNIQ_ERROR = 1052\nSERVER_SHUTDOWN = 1053\nBAD_FIELD_ERROR = 1054\nWRONG_FIELD_WITH_GROUP = 1055\nWRONG_GROUP_FIELD = 1056\nWRONG_SUM_SELECT = 1057\nWRONG_VALUE_COUNT = 1058\nTOO_LONG_IDENT = 1059\nDUP_FIELDNAME = 1060\nDUP_KEYNAME = 1061\nDUP_ENTRY = 1062\nWRONG_FIELD_SPEC = 1063\nPARSE_ERROR = 1064\nEMPTY_QUERY = 1065\nNONUNIQ_TABLE = 1066\nINVALID_DEFAULT = 1067\nMULTIPLE_PRI_KEY = 1068\nTOO_MANY_KEYS = 1069\nTOO_MANY_KEY_PARTS = 1070\nTOO_LONG_KEY = 1071\nKEY_COLUMN_DOES_NOT_EXITS = 1072\nBLOB_USED_AS_KEY = 1073\nTOO_BIG_FIELDLENGTH = 1074\nWRONG_AUTO_KEY = 1075\nREADY = 1076\nNORMAL_SHUTDOWN = 1077\nGOT_SIGNAL = 1078\nSHUTDOWN_COMPLETE = 1079\nFORCING_CLOSE = 1080\nIPSOCK_ERROR = 1081\nNO_SUCH_INDEX = 1082\nWRONG_FIELD_TERMINATORS = 1083\nBLOBS_AND_NO_TERMINATED = 1084\nTEXTFILE_NOT_READABLE = 1085\nFILE_EXISTS_ERROR = 1086\nLOAD_INFO = 1087\nALTER_INFO = 1088\nWRONG_SUB_KEY = 1089\nCANT_REMOVE_ALL_FIELDS = 1090\nCANT_DROP_FIELD_OR_KEY = 1091\nINSERT_INFO = 1092\nINSERT_TABLE_USED = 1093\nNO_SUCH_THREAD = 1094\nKILL_DENIED_ERROR = 1095\nNO_TABLES_USED = 1096\nTOO_BIG_SET = 1097\nNO_UNIQUE_LOGFILE = 1098\nTABLE_NOT_LOCKED_FOR_WRITE = 1099\nTABLE_NOT_LOCKED = 1100\nBLOB_CANT_HAVE_DEFAULT = 1101\nWRONG_DB_NAME = 1102\nWRONG_TABLE_NAME = 1103\nTOO_BIG_SELECT = 1104\nUNKNOWN_ERROR = 1105\nUNKNOWN_PROCEDURE = 1106\nWRONG_PARAMCOUNT_TO_PROCEDURE = 1107\nWRONG_PARAMETERS_TO_PROCEDURE = 1108\nUNKNOWN_TABLE = 1109\nFIELD_SPECIFIED_TWICE = 1110\nINVALID_GROUP_FUNC_USE = 1111\nUNSUPPORTED_EXTENSION = 1112\nTABLE_MUST_HAVE_COLUMNS = 1113\nRECORD_FILE_FULL = 1114\nUNKNOWN_CHARACTER_SET = 1115\nTOO_MANY_TABLES = 1116\nTOO_MANY_FIELDS = 1117\nTOO_BIG_ROWSIZE = 1118\nSTACK_OVERRUN = 1119\nWRONG_OUTER_JOIN = 1120\nNULL_COLUMN_IN_INDEX = 1121\nCANT_FIND_UDF = 1122\nCANT_INITIALIZE_UDF = 1123\nUDF_NO_PATHS = 1124\nUDF_EXISTS = 1125\nCANT_OPEN_LIBRARY = 1126\nCANT_FIND_DL_ENTRY = 1127\nFUNCTION_NOT_DEFINED = 1128\nHOST_IS_BLOCKED = 1129\nHOST_NOT_PRIVILEGED = 1130\nPASSWORD_ANONYMOUS_USER = 1131\nPASSWORD_NOT_ALLOWED = 1132\nPASSWORD_NO_MATCH = 1133\nUPDATE_INFO = 1134\nCANT_CREATE_THREAD = 1135\nWRONG_VALUE_COUNT_ON_ROW = 1136\nCANT_REOPEN_TABLE = 1137\nINVALID_USE_OF_NULL = 1138\nREGEXP_ERROR = 1139\nMIX_OF_GROUP_FUNC_AND_FIELDS = 1140\nNONEXISTING_GRANT = 1141\nTABLEACCESS_DENIED_ERROR = 1142\nCOLUMNACCESS_DENIED_ERROR = 1143\nILLEGAL_GRANT_FOR_TABLE = 1144\nGRANT_WRONG_HOST_OR_USER = 1145\nNO_SUCH_TABLE = 1146\nNONEXISTING_TABLE_GRANT = 1147\nNOT_ALLOWED_COMMAND = 1148\nSYNTAX_ERROR = 1149\nDELAYED_CANT_CHANGE_LOCK = 1150\nTOO_MANY_DELAYED_THREADS = 1151\nABORTING_CONNECTION = 1152\nNET_PACKET_TOO_LARGE = 1153\nNET_READ_ERROR_FROM_PIPE = 1154\nNET_FCNTL_ERROR = 1155\nNET_PACKETS_OUT_OF_ORDER = 1156\nNET_UNCOMPRESS_ERROR = 1157\nNET_READ_ERROR = 1158\nNET_READ_INTERRUPTED = 1159\nNET_ERROR_ON_WRITE = 1160\nNET_WRITE_INTERRUPTED = 1161\nTOO_LONG_STRING = 1162\nTABLE_CANT_HANDLE_BLOB = 1163\nTABLE_CANT_HANDLE_AUTO_INCREMENT = 1164\nDELAYED_INSERT_TABLE_LOCKED = 1165\nWRONG_COLUMN_NAME = 1166\nWRONG_KEY_COLUMN = 1167\nWRONG_MRG_TABLE = 1168\nDUP_UNIQUE = 1169\nBLOB_KEY_WITHOUT_LENGTH = 1170\nPRIMARY_CANT_HAVE_NULL = 1171\nTOO_MANY_ROWS = 1172\nREQUIRES_PRIMARY_KEY = 1173\nNO_RAID_COMPILED = 1174\nUPDATE_WITHOUT_KEY_IN_SAFE_MODE = 1175\nKEY_DOES_NOT_EXITS = 1176\nCHECK_NO_SUCH_TABLE = 1177\nCHECK_NOT_IMPLEMENTED = 1178\nCANT_DO_THIS_DURING_AN_TRANSACTION = 1179\nERROR_DURING_COMMIT = 1180\nERROR_DURING_ROLLBACK = 1181\nERROR_DURING_FLUSH_LOGS = 1182\nERROR_DURING_CHECKPOINT = 1183\nNEW_ABORTING_CONNECTION = 1184\nDUMP_NOT_IMPLEMENTED = 1185\nFLUSH_MASTER_BINLOG_CLOSED = 1186\nINDEX_REBUILD = 1187\nMASTER = 1188\nMASTER_NET_READ = 1189\nMASTER_NET_WRITE = 1190\nFT_MATCHING_KEY_NOT_FOUND = 1191\nLOCK_OR_ACTIVE_TRANSACTION = 1192\nUNKNOWN_SYSTEM_VARIABLE = 1193\nCRASHED_ON_USAGE = 1194\nCRASHED_ON_REPAIR = 1195\nWARNING_NOT_COMPLETE_ROLLBACK = 1196\nTRANS_CACHE_FULL = 1197\nSLAVE_MUST_STOP = 1198\nSLAVE_NOT_RUNNING = 1199\nBAD_SLAVE = 1200\nMASTER_INFO = 1201\nSLAVE_THREAD = 1202\nTOO_MANY_USER_CONNECTIONS = 1203\nSET_CONSTANTS_ONLY = 1204\nLOCK_WAIT_TIMEOUT = 1205\nLOCK_TABLE_FULL = 1206\nREAD_ONLY_TRANSACTION = 1207\nDROP_DB_WITH_READ_LOCK = 1208\nCREATE_DB_WITH_READ_LOCK = 1209\nWRONG_ARGUMENTS = 1210\nNO_PERMISSION_TO_CREATE_USER = 1211\nUNION_TABLES_IN_DIFFERENT_DIR = 1212\nLOCK_DEADLOCK = 1213\nTABLE_CANT_HANDLE_FT = 1214\nCANNOT_ADD_FOREIGN = 1215\nNO_REFERENCED_ROW = 1216\nROW_IS_REFERENCED = 1217\nCONNECT_TO_MASTER = 1218\nQUERY_ON_MASTER = 1219\nERROR_WHEN_EXECUTING_COMMAND = 1220\nWRONG_USAGE = 1221\nWRONG_NUMBER_OF_COLUMNS_IN_SELECT = 1222\nCANT_UPDATE_WITH_READLOCK = 1223\nMIXING_NOT_ALLOWED = 1224\nDUP_ARGUMENT = 1225\nUSER_LIMIT_REACHED = 1226\nSPECIFIC_ACCESS_DENIED_ERROR = 1227\nLOCAL_VARIABLE = 1228\nGLOBAL_VARIABLE = 1229\nNO_DEFAULT = 1230\nWRONG_VALUE_FOR_VAR = 1231\nWRONG_TYPE_FOR_VAR = 1232\nVAR_CANT_BE_READ = 1233\nCANT_USE_OPTION_HERE = 1234\nNOT_SUPPORTED_YET = 1235\nMASTER_FATAL_ERROR_READING_BINLOG = 1236\nSLAVE_IGNORED_TABLE = 1237\nINCORRECT_GLOBAL_LOCAL_VAR = 1238\nWRONG_FK_DEF = 1239\nKEY_REF_DO_NOT_MATCH_TABLE_REF = 1240\nOPERAND_COLUMNS = 1241\nSUBQUERY_NO_1_ROW = 1242\nUNKNOWN_STMT_HANDLER = 1243\nCORRUPT_HELP_DB = 1244\nCYCLIC_REFERENCE = 1245\nAUTO_CONVERT = 1246\nILLEGAL_REFERENCE = 1247\nDERIVED_MUST_HAVE_ALIAS = 1248\nSELECT_REDUCED = 1249\nTABLENAME_NOT_ALLOWED_HERE = 1250\nNOT_SUPPORTED_AUTH_MODE = 1251\nSPATIAL_CANT_HAVE_NULL = 1252\nCOLLATION_CHARSET_MISMATCH = 1253\nSLAVE_WAS_RUNNING = 1254\nSLAVE_WAS_NOT_RUNNING = 1255\nTOO_BIG_FOR_UNCOMPRESS = 1256\nZLIB_Z_MEM_ERROR = 1257\nZLIB_Z_BUF_ERROR = 1258\nZLIB_Z_DATA_ERROR = 1259\nCUT_VALUE_GROUP_CONCAT = 1260\nWARN_TOO_FEW_RECORDS = 1261\nWARN_TOO_MANY_RECORDS = 1262\nWARN_NULL_TO_NOTNULL = 1263\nWARN_DATA_OUT_OF_RANGE = 1264\nWARN_DATA_TRUNCATED = 1265\nWARN_USING_OTHER_HANDLER = 1266\nCANT_AGGREGATE_2COLLATIONS = 1267\nDROP_USER = 1268\nREVOKE_GRANTS = 1269\nCANT_AGGREGATE_3COLLATIONS = 1270\nCANT_AGGREGATE_NCOLLATIONS = 1271\nVARIABLE_IS_NOT_STRUCT = 1272\nUNKNOWN_COLLATION = 1273\nSLAVE_IGNORED_SSL_PARAMS = 1274\nSERVER_IS_IN_SECURE_AUTH_MODE = 1275\nWARN_FIELD_RESOLVED = 1276\nBAD_SLAVE_UNTIL_COND = 1277\nMISSING_SKIP_SLAVE = 1278\nUNTIL_COND_IGNORED = 1279\nWRONG_NAME_FOR_INDEX = 1280\nWRONG_NAME_FOR_CATALOG = 1281\nWARN_QC_RESIZE = 1282\nBAD_FT_COLUMN = 1283\nUNKNOWN_KEY_CACHE = 1284\nWARN_HOSTNAME_WONT_WORK = 1285\nUNKNOWN_STORAGE_ENGINE = 1286\nWARN_DEPRECATED_SYNTAX = 1287\nNON_UPDATABLE_TABLE = 1288\nFEATURE_DISABLED = 1289\nOPTION_PREVENTS_STATEMENT = 1290\nDUPLICATED_VALUE_IN_TYPE = 1291\nTRUNCATED_WRONG_VALUE = 1292\nTOO_MUCH_AUTO_TIMESTAMP_COLS = 1293\nINVALID_ON_UPDATE = 1294\nUNSUPPORTED_PS = 1295\nGET_ERRMSG = 1296\nGET_TEMPORARY_ERRMSG = 1297\nUNKNOWN_TIME_ZONE = 1298\nWARN_INVALID_TIMESTAMP = 1299\nINVALID_CHARACTER_STRING = 1300\nWARN_ALLOWED_PACKET_OVERFLOWED = 1301\nCONFLICTING_DECLARATIONS = 1302\nSP_NO_RECURSIVE_CREATE = 1303\nSP_ALREADY_EXISTS = 1304\nSP_DOES_NOT_EXIST = 1305\nSP_DROP_FAILED = 1306\nSP_STORE_FAILED = 1307\nSP_LILABEL_MISMATCH = 1308\nSP_LABEL_REDEFINE = 1309\nSP_LABEL_MISMATCH = 1310\nSP_UNINIT_VAR = 1311\nSP_BADSELECT = 1312\nSP_BADRETURN = 1313\nSP_BADSTATEMENT = 1314\nUPDATE_LOG_DEPRECATED_IGNORED = 1315\nUPDATE_LOG_DEPRECATED_TRANSLATED = 1316\nQUERY_INTERRUPTED = 1317\nSP_WRONG_NO_OF_ARGS = 1318\nSP_COND_MISMATCH = 1319\nSP_NORETURN = 1320\nSP_NORETURNEND = 1321\nSP_BAD_CURSOR_QUERY = 1322\nSP_BAD_CURSOR_SELECT = 1323\nSP_CURSOR_MISMATCH = 1324\nSP_CURSOR_ALREADY_OPEN = 1325\nSP_CURSOR_NOT_OPEN = 1326\nSP_UNDECLARED_VAR = 1327\nSP_WRONG_NO_OF_FETCH_ARGS = 1328\nSP_FETCH_NO_DATA = 1329\nSP_DUP_PARAM = 1330\nSP_DUP_VAR = 1331\nSP_DUP_COND = 1332\nSP_DUP_CURS = 1333\nSP_CANT_ALTER = 1334\nSP_SUBSELECT_NYI = 1335\nSTMT_NOT_ALLOWED_IN_SF_OR_TRG = 1336\nSP_VARCOND_AFTER_CURSHNDLR = 1337\nSP_CURSOR_AFTER_HANDLER = 1338\nSP_CASE_NOT_FOUND = 1339\nFPARSER_TOO_BIG_FILE = 1340\nFPARSER_BAD_HEADER = 1341\nFPARSER_EOF_IN_COMMENT = 1342\nFPARSER_ERROR_IN_PARAMETER = 1343\nFPARSER_EOF_IN_UNKNOWN_PARAMETER = 1344\nVIEW_NO_EXPLAIN = 1345\nFRM_UNKNOWN_TYPE = 1346\nWRONG_OBJECT = 1347\nNONUPDATEABLE_COLUMN = 1348\nVIEW_SELECT_DERIVED = 1349\nVIEW_SELECT_CLAUSE = 1350\nVIEW_SELECT_VARIABLE = 1351\nVIEW_SELECT_TMPTABLE = 1352\nVIEW_WRONG_LIST = 1353\nWARN_VIEW_MERGE = 1354\nWARN_VIEW_WITHOUT_KEY = 1355\nVIEW_INVALID = 1356\nSP_NO_DROP_SP = 1357\nSP_GOTO_IN_HNDLR = 1358\nTRG_ALREADY_EXISTS = 1359\nTRG_DOES_NOT_EXIST = 1360\nTRG_ON_VIEW_OR_TEMP_TABLE = 1361\nTRG_CANT_CHANGE_ROW = 1362\nTRG_NO_SUCH_ROW_IN_TRG = 1363\nNO_DEFAULT_FOR_FIELD = 1364\nDIVISION_BY_ZERO = 1365\nTRUNCATED_WRONG_VALUE_FOR_FIELD = 1366\nILLEGAL_VALUE_FOR_TYPE = 1367\nVIEW_NONUPD_CHECK = 1368\nVIEW_CHECK_FAILED = 1369\nPROCACCESS_DENIED_ERROR = 1370\nRELAY_LOG_FAIL = 1371\nPASSWD_LENGTH = 1372\nUNKNOWN_TARGET_BINLOG = 1373\nIO_ERR_LOG_INDEX_READ = 1374\nBINLOG_PURGE_PROHIBITED = 1375\nFSEEK_FAIL = 1376\nBINLOG_PURGE_FATAL_ERR = 1377\nLOG_IN_USE = 1378\nLOG_PURGE_UNKNOWN_ERR = 1379\nRELAY_LOG_INIT = 1380\nNO_BINARY_LOGGING = 1381\nRESERVED_SYNTAX = 1382\nWSAS_FAILED = 1383\nDIFF_GROUPS_PROC = 1384\nNO_GROUP_FOR_PROC = 1385\nORDER_WITH_PROC = 1386\nLOGGING_PROHIBIT_CHANGING_OF = 1387\nNO_FILE_MAPPING = 1388\nWRONG_MAGIC = 1389\nPS_MANY_PARAM = 1390\nKEY_PART_0 = 1391\nVIEW_CHECKSUM = 1392\nVIEW_MULTIUPDATE = 1393\nVIEW_NO_INSERT_FIELD_LIST = 1394\nVIEW_DELETE_MERGE_VIEW = 1395\nCANNOT_USER = 1396\nXAER_NOTA = 1397\nXAER_INVAL = 1398\nXAER_RMFAIL = 1399\nXAER_OUTSIDE = 1400\nXAER_RMERR = 1401\nXA_RBROLLBACK = 1402\nNONEXISTING_PROC_GRANT = 1403\nPROC_AUTO_GRANT_FAIL = 1404\nPROC_AUTO_REVOKE_FAIL = 1405\nDATA_TOO_LONG = 1406\nSP_BAD_SQLSTATE = 1407\nSTARTUP = 1408\nLOAD_FROM_FIXED_SIZE_ROWS_TO_VAR = 1409\nCANT_CREATE_USER_WITH_GRANT = 1410\nWRONG_VALUE_FOR_TYPE = 1411\nTABLE_DEF_CHANGED = 1412\nSP_DUP_HANDLER = 1413\nSP_NOT_VAR_ARG = 1414\nSP_NO_RETSET = 1415\nCANT_CREATE_GEOMETRY_OBJECT = 1416\nFAILED_ROUTINE_BREAK_BINLOG = 1417\nBINLOG_UNSAFE_ROUTINE = 1418\nBINLOG_CREATE_ROUTINE_NEED_SUPER = 1419\nEXEC_STMT_WITH_OPEN_CURSOR = 1420\nSTMT_HAS_NO_OPEN_CURSOR = 1421\nCOMMIT_NOT_ALLOWED_IN_SF_OR_TRG = 1422\nNO_DEFAULT_FOR_VIEW_FIELD = 1423\nSP_NO_RECURSION = 1424\nTOO_BIG_SCALE = 1425\nTOO_BIG_PRECISION = 1426\nM_BIGGER_THAN_D = 1427\nWRONG_LOCK_OF_SYSTEM_TABLE = 1428\nCONNECT_TO_FOREIGN_DATA_SOURCE = 1429\nQUERY_ON_FOREIGN_DATA_SOURCE = 1430\nFOREIGN_DATA_SOURCE_DOESNT_EXIST = 1431\nFOREIGN_DATA_STRING_INVALID_CANT_CREATE = 1432\nFOREIGN_DATA_STRING_INVALID = 1433\nCANT_CREATE_FEDERATED_TABLE = 1434\nTRG_IN_WRONG_SCHEMA = 1435\nSTACK_OVERRUN_NEED_MORE = 1436\nTOO_LONG_BODY = 1437\nWARN_CANT_DROP_DEFAULT_KEYCACHE = 1438\nTOO_BIG_DISPLAYWIDTH = 1439\nXAER_DUPID = 1440\nDATETIME_FUNCTION_OVERFLOW = 1441\nCANT_UPDATE_USED_TABLE_IN_SF_OR_TRG = 1442\nVIEW_PREVENT_UPDATE = 1443\nPS_NO_RECURSION = 1444\nSP_CANT_SET_AUTOCOMMIT = 1445\nMALFORMED_DEFINER = 1446\nVIEW_FRM_NO_USER = 1447\nVIEW_OTHER_USER = 1448\nNO_SUCH_USER = 1449\nFORBID_SCHEMA_CHANGE = 1450\nROW_IS_REFERENCED_2 = 1451\nNO_REFERENCED_ROW_2 = 1452\nSP_BAD_VAR_SHADOW = 1453\nTRG_NO_DEFINER = 1454\nOLD_FILE_FORMAT = 1455\nSP_RECURSION_LIMIT = 1456\nSP_PROC_TABLE_CORRUPT = 1457\nERROR_LAST = 1457\n\n"
  },
  {
    "path": "MySQLdb/constants/FIELD_TYPE.py",
    "content": "\"\"\"MySQL FIELD_TYPE Constants\n\nThese constants represent the various column (field) types that are\nsupported by MySQL.\n\n\"\"\"\n\nDECIMAL = 0\nTINY = 1\nSHORT = 2\nLONG = 3\nFLOAT = 4\nDOUBLE = 5\nNULL = 6\nTIMESTAMP = 7\nLONGLONG = 8\nINT24 = 9\nDATE = 10\nTIME = 11\nDATETIME = 12\nYEAR = 13\nNEWDATE = 14\nVARCHAR = 15\nBIT = 16\nNEWDECIMAL = 246\nENUM = 247\nSET = 248\nTINY_BLOB = 249\nMEDIUM_BLOB = 250\nLONG_BLOB = 251\nBLOB = 252\nVAR_STRING = 253\nSTRING = 254\nGEOMETRY = 255\n\nCHAR = TINY\nINTERVAL = ENUM\t\n"
  },
  {
    "path": "MySQLdb/constants/FLAG.py",
    "content": "\"\"\"MySQL FLAG Constants\n\nThese flags are used along with the FIELD_TYPE to indicate various\nproperties of columns in a result set.\n\n\"\"\"\n\nNOT_NULL = 1\nPRI_KEY = 2\nUNIQUE_KEY = 4\nMULTIPLE_KEY = 8\nBLOB = 16\nUNSIGNED = 32\nZEROFILL = 64\nBINARY = 128\nENUM = 256\nAUTO_INCREMENT = 512\nTIMESTAMP = 1024\nSET = 2048\nNUM = 32768\nPART_KEY = 16384\nGROUP = 32768\nUNIQUE = 65536\n"
  },
  {
    "path": "MySQLdb/constants/REFRESH.py",
    "content": "\"\"\"MySQL REFRESH Constants\n\nThese constants seem to mostly deal with things internal to the\nMySQL server. Forget you saw this.\n\n\"\"\"\n\nGRANT = 1\nLOG = 2\nTABLES = 4\nHOSTS = 8\nSTATUS = 16\nTHREADS = 32\nSLAVE = 64\nMASTER = 128\nREAD_LOCK = 16384\nFAST = 32768\n"
  },
  {
    "path": "MySQLdb/constants/__init__.py",
    "content": "__all__ = ['CR', 'FIELD_TYPE','CLIENT','REFRESH','ER','FLAG']\n"
  },
  {
    "path": "MySQLdb/converters.py",
    "content": "\"\"\"MySQLdb type conversion module\n\nThis module handles all the type conversions for MySQL. If the default\ntype conversions aren't what you need, you can make your own. The\ndictionary conversions maps some kind of type to a conversion function\nwhich returns the corresponding value:\n\nKey: FIELD_TYPE.* (from MySQLdb.constants)\n\nConversion function:\n\n    Arguments: string\n\n    Returns: Python object\n\nKey: Python type object (from types) or class\n\nConversion function:\n\n    Arguments: Python object of indicated type or class AND \n               conversion dictionary\n\n    Returns: SQL literal value\n\n    Notes: Most conversion functions can ignore the dictionary, but\n           it is a required parameter. It is necessary for converting\n           things like sequences and instances.\n\nDon't modify conversions if you can avoid it. Instead, make copies\n(with the copy() method), modify the copies, and then pass them to\nMySQL.connect().\n\n\"\"\"\n\nfrom _mysql import string_literal, escape_sequence, escape_dict, escape, NULL\nfrom MySQLdb.constants import FIELD_TYPE, FLAG\nfrom MySQLdb.times import *\n\ntry:\n    from types import IntType, LongType, FloatType, NoneType, TupleType, ListType, DictType, InstanceType, \\\n        StringType, UnicodeType, ObjectType, BooleanType, ClassType, TypeType\nexcept ImportError:\n    # Python 3\n    long = int\n    IntType, LongType, FloatType, NoneType = int, long, float, type(None)\n    TupleType, ListType, DictType, InstanceType = tuple, list, dict, None\n    StringType, UnicodeType, ObjectType, BooleanType = bytes, str, object, bool\n\nimport array\n\ntry:\n    ArrayType = array.ArrayType\nexcept AttributeError:\n    ArrayType = array.array\n\ntry:\n    set\nexcept NameError:\n    from sets import Set as set\n\ndef Bool2Str(s, d): return str(int(s))\n\ndef Str2Set(s):\n    return set([ i for i in s.split(',') if i ])\n\ndef Set2Str(s, d):\n    return string_literal(','.join(s), d)\n    \ndef Thing2Str(s, d):\n    \"\"\"Convert something into a string via str().\"\"\"\n    return str(s)\n\ndef Unicode2Str(s, d):\n    \"\"\"Convert a unicode object to a string using the default encoding.\n    This is only used as a placeholder for the real function, which\n    is connection-dependent.\"\"\"\n    return s.encode()\n\nLong2Int = Thing2Str\n\ndef Float2Str(o, d):\n    return '%.15g' % o\n\ndef None2NULL(o, d):\n    \"\"\"Convert None to NULL.\"\"\"\n    return NULL # duh\n\ndef Thing2Literal(o, d):\n    \n    \"\"\"Convert something into a SQL string literal.  If using\n    MySQL-3.23 or newer, string_literal() is a method of the\n    _mysql.MYSQL object, and this function will be overridden with\n    that method when the connection is created.\"\"\"\n\n    return string_literal(o, d)\n\n\ndef Instance2Str(o, d):\n\n    \"\"\"\n\n    Convert an Instance to a string representation.  If the __str__()\n    method produces acceptable output, then you don't need to add the\n    class to conversions; it will be handled by the default\n    converter. If the exact class is not found in d, it will use the\n    first class it can find for which o is an instance.\n\n    \"\"\"\n\n    if o.__class__ in d:\n        return d[o.__class__](o, d)\n    cl = filter(lambda x,o=o:\n                type(x) is ClassType\n                and isinstance(o, x), d.keys())\n    if not cl:\n        cl = filter(lambda x,o=o:\n                    type(x) is TypeType\n                    and isinstance(o, x)\n                    and d[x] is not Instance2Str,\n                    d.keys())\n    if not cl:\n        return d[StringType](o,d)\n    d[o.__class__] = d[cl[0]]\n    return d[cl[0]](o, d)\n\ndef char_array(s):\n    return array.array('c', s)\n\ndef array2Str(o, d):\n    return Thing2Literal(o.tostring(), d)\n\ndef quote_tuple(t, d):\n    return \"(%s)\" % (','.join(escape_sequence(t, d)))\n\nconversions = {\n    IntType: Thing2Str,\n    LongType: Long2Int,\n    FloatType: Float2Str,\n    NoneType: None2NULL,\n    TupleType: quote_tuple,\n    ListType: quote_tuple,\n    DictType: escape_dict,\n    InstanceType: Instance2Str,\n    ArrayType: array2Str,\n    StringType: Thing2Literal, # default\n    UnicodeType: Unicode2Str,\n    ObjectType: Instance2Str,\n    BooleanType: Bool2Str,\n    DateTimeType: DateTime2literal,\n    DateTimeDeltaType: DateTimeDelta2literal,\n    set: Set2Str,\n    FIELD_TYPE.TINY: int,\n    FIELD_TYPE.SHORT: int,\n    FIELD_TYPE.LONG: long,\n    FIELD_TYPE.FLOAT: float,\n    FIELD_TYPE.DOUBLE: float,\n    FIELD_TYPE.DECIMAL: float,\n    FIELD_TYPE.NEWDECIMAL: float,\n    FIELD_TYPE.LONGLONG: long,\n    FIELD_TYPE.INT24: int,\n    FIELD_TYPE.YEAR: int,\n    FIELD_TYPE.SET: Str2Set,\n    FIELD_TYPE.TIMESTAMP: mysql_timestamp_converter,\n    FIELD_TYPE.DATETIME: DateTime_or_None,\n    FIELD_TYPE.TIME: TimeDelta_or_None,\n    FIELD_TYPE.DATE: Date_or_None,\n    FIELD_TYPE.BLOB: [\n        (FLAG.BINARY, str),\n        ],\n    FIELD_TYPE.STRING: [\n        (FLAG.BINARY, str),\n        ],\n    FIELD_TYPE.VAR_STRING: [\n        (FLAG.BINARY, str),\n        ],\n    FIELD_TYPE.VARCHAR: [\n        (FLAG.BINARY, str),\n        ],\n    }\n\ntry:\n    from decimal import Decimal\n    conversions[FIELD_TYPE.DECIMAL] = Decimal\n    conversions[FIELD_TYPE.NEWDECIMAL] = Decimal\nexcept ImportError:\n    pass\n\n\n\n"
  },
  {
    "path": "MySQLdb/cursors.py",
    "content": "\"\"\"MySQLdb Cursors\n\nThis module implements Cursors of various types for MySQLdb. By\ndefault, MySQLdb uses the Cursor class.\n\n\"\"\"\n\nimport re\nimport sys\ntry:\n    from types import ListType, TupleType, UnicodeType\nexcept ImportError:\n    # Python 3\n    ListType = list\n    TupleType = tuple\n    UnicodeType = str\n\nrestr = r\"\"\"\n    \\s\n    values\n    \\s*\n    (\n        \\(\n            [^()']*\n            (?:\n                (?:\n                        (?:\\(\n                            # ( - editor hightlighting helper\n                            .*\n                        \\))\n                    |\n                        '\n                            [^\\\\']*\n                            (?:\\\\.[^\\\\']*)*\n                        '\n                )\n                [^()']*\n            )*\n        \\)\n    )\n\"\"\"\n\ninsert_values = re.compile(restr, re.S | re.I | re.X)\n\nfrom _mysql_exceptions import Warning, Error, InterfaceError, DataError, \\\n     DatabaseError, OperationalError, IntegrityError, InternalError, \\\n     NotSupportedError, ProgrammingError\n\n\nclass BaseCursor(object):\n    \n    \"\"\"A base for Cursor classes. Useful attributes:\n    \n    description\n        A tuple of DB API 7-tuples describing the columns in\n        the last executed query; see PEP-249 for details.\n\n    description_flags\n        Tuple of column flags for last query, one entry per column\n        in the result set. Values correspond to those in\n        MySQLdb.constants.FLAG. See MySQL documentation (C API)\n        for more information. Non-standard extension.\n    \n    arraysize\n        default number of rows fetchmany() will fetch\n\n    \"\"\"\n\n    from _mysql_exceptions import MySQLError, Warning, Error, InterfaceError, \\\n         DatabaseError, DataError, OperationalError, IntegrityError, \\\n         InternalError, ProgrammingError, NotSupportedError\n    \n    _defer_warnings = False\n    \n    def __init__(self, connection):\n        from weakref import proxy\n    \n        self.connection = proxy(connection)\n        self.description = None\n        self.description_flags = None\n        self.rowcount = -1\n        self.arraysize = 1\n        self._executed = None\n        self.lastrowid = None\n        self.messages = []\n        self.errorhandler = connection.errorhandler\n        self._result = None\n        self._warnings = 0\n        self._info = None\n        self.rownumber = None\n        \n    def __del__(self):\n        self.close()\n        self.errorhandler = None\n        self._result = None\n\n    def close(self):\n        \"\"\"Close the cursor. No further queries will be possible.\"\"\"\n        if not self.connection: return\n        while self.nextset(): pass\n        self.connection = None\n\n    def _check_executed(self):\n        if not self._executed:\n            self.errorhandler(self, ProgrammingError, \"execute() first\")\n\n    def _warning_check(self):\n        from warnings import warn\n        if self._warnings:\n            warnings = self._get_db().show_warnings()\n            if warnings:\n                # This is done in two loops in case\n                # Warnings are set to raise exceptions.\n                for w in warnings:\n                    self.messages.append((self.Warning, w))\n                for w in warnings:\n                    warn(w[-1], self.Warning, 3)\n            elif self._info:\n                self.messages.append((self.Warning, self._info))\n                warn(self._info, self.Warning, 3)\n\n    def nextset(self):\n        \"\"\"Advance to the next result set.\n\n        Returns None if there are no more result sets.\n        \"\"\"\n        if self._executed:\n            self.fetchall()\n        del self.messages[:]\n        \n        db = self._get_db()\n        nr = db.next_result()\n        if nr == -1:\n            return None\n        self._do_get_result()\n        self._post_get_result()\n        self._warning_check()\n        return 1\n\n    def _post_get_result(self): pass\n    \n    def _do_get_result(self):\n        db = self._get_db()\n        self._result = self._get_result()\n        self.rowcount = db.affected_rows()\n        self.rownumber = 0\n        self.description = self._result and self._result.describe() or None\n        self.description_flags = self._result and self._result.field_flags() or None\n        self.lastrowid = db.insert_id()\n        self._warnings = db.warning_count()\n        self._info = db.info()\n    \n    def setinputsizes(self, *args):\n        \"\"\"Does nothing, required by DB API.\"\"\"\n      \n    def setoutputsizes(self, *args):\n        \"\"\"Does nothing, required by DB API.\"\"\"\n\n    def _get_db(self):\n        if not self.connection:\n            self.errorhandler(self, ProgrammingError, \"cursor closed\")\n        return self.connection\n    \n    def execute(self, query, args=None):\n\n        \"\"\"Execute a query.\n        \n        query -- string, query to execute on server\n        args -- optional sequence or mapping, parameters to use with query.\n\n        Note: If args is a sequence, then %s must be used as the\n        parameter placeholder in the query. If a mapping is used,\n        %(key)s must be used as the placeholder.\n\n        Returns long integer rows affected, if any\n\n        \"\"\"\n        del self.messages[:]\n        db = self._get_db()\n        if isinstance(query, unicode):\n            query = query.encode(db.unicode_literal.charset)\n        if args is not None:\n            if isinstance(args, dict):\n                query = query % dict((key, db.literal(item))\n                                     for key, item in args.iteritems())\n            else:\n                query = query % tuple([db.literal(item) for item in args])\n        try:\n            r = None\n            r = self._query(query)\n        except TypeError, m:\n            if m.args[0] in (\"not enough arguments for format string\",\n                             \"not all arguments converted\"):\n                self.messages.append((ProgrammingError, m.args[0]))\n                self.errorhandler(self, ProgrammingError, m.args[0])\n            else:\n                self.messages.append((TypeError, m))\n                self.errorhandler(self, TypeError, m)\n        except (SystemExit, KeyboardInterrupt):\n            raise\n        except:\n            exc, value, tb = sys.exc_info()\n            del tb\n            self.messages.append((exc, value))\n            self.errorhandler(self, exc, value)\n        self._executed = query\n        if not self._defer_warnings: self._warning_check()\n        return r\n\n    def executemany(self, query, args):\n\n        \"\"\"Execute a multi-row query.\n        \n        query -- string, query to execute on server\n\n        args\n\n            Sequence of sequences or mappings, parameters to use with\n            query.\n            \n        Returns long integer rows affected, if any.\n        \n        This method improves performance on multiple-row INSERT and\n        REPLACE. Otherwise it is equivalent to looping over args with\n        execute().\n\n        \"\"\"\n        del self.messages[:]\n        db = self._get_db()\n        if not args: return\n        if isinstance(query, unicode):\n            query = query.encode(db.unicode_literal.charset)\n        m = insert_values.search(query)\n        if not m:\n            r = 0\n            for a in args:\n                r = r + self.execute(query, a)\n            return r\n        p = m.start(1)\n        e = m.end(1)\n        qv = m.group(1)\n        try:\n            q = []\n            for a in args:\n                if isinstance(a, dict):\n                    q.append(qv % dict((key, db.literal(item))\n                                       for key, item in a.iteritems()))\n                else:\n                    q.append(qv % tuple([db.literal(item) for item in a]))\n        except TypeError, msg:\n            if msg.args[0] in (\"not enough arguments for format string\",\n                               \"not all arguments converted\"):\n                self.errorhandler(self, ProgrammingError, msg.args[0])\n            else:\n                self.errorhandler(self, TypeError, msg)\n        except (SystemExit, KeyboardInterrupt):\n            raise\n        except:\n            exc, value, tb = sys.exc_info()\n            del tb\n            self.errorhandler(self, exc, value)\n        r = self._query('\\n'.join([query[:p], ',\\n'.join(q), query[e:]]))\n        if not self._defer_warnings: self._warning_check()\n        return r\n    \n    def callproc(self, procname, args=()):\n\n        \"\"\"Execute stored procedure procname with args\n        \n        procname -- string, name of procedure to execute on server\n\n        args -- Sequence of parameters to use with procedure\n\n        Returns the original args.\n\n        Compatibility warning: PEP-249 specifies that any modified\n        parameters must be returned. This is currently impossible\n        as they are only available by storing them in a server\n        variable and then retrieved by a query. Since stored\n        procedures return zero or more result sets, there is no\n        reliable way to get at OUT or INOUT parameters via callproc.\n        The server variables are named @_procname_n, where procname\n        is the parameter above and n is the position of the parameter\n        (from zero). Once all result sets generated by the procedure\n        have been fetched, you can issue a SELECT @_procname_0, ...\n        query using .execute() to get any OUT or INOUT values.\n\n        Compatibility warning: The act of calling a stored procedure\n        itself creates an empty result set. This appears after any\n        result sets generated by the procedure. This is non-standard\n        behavior with respect to the DB-API. Be sure to use nextset()\n        to advance through all result sets; otherwise you may get\n        disconnected.\n        \"\"\"\n\n        db = self._get_db()\n        for index, arg in enumerate(args):\n            q = \"SET @_%s_%d=%s\" % (procname, index,\n                                         db.literal(arg))\n            if isinstance(q, unicode):\n                q = q.encode(db.unicode_literal.charset)\n            self._query(q)\n            self.nextset()\n            \n        q = \"CALL %s(%s)\" % (procname,\n                             ','.join(['@_%s_%d' % (procname, i)\n                                       for i in range(len(args))]))\n        if type(q) is UnicodeType:\n            q = q.encode(db.unicode_literal.charset)\n        self._query(q)\n        self._executed = q\n        if not self._defer_warnings: self._warning_check()\n        return args\n    \n    def _do_query(self, q):\n        db = self._get_db()\n        self._last_executed = q\n        db.query(q)\n        self._do_get_result()\n        return self.rowcount\n\n    def _query(self, q): return self._do_query(q)\n    \n    def _fetch_row(self, size=1):\n        if not self._result:\n            return ()\n        return self._result.fetch_row(size, self._fetch_type)\n\n    def __iter__(self):\n        return iter(self.fetchone, None)\n\n    Warning = Warning\n    Error = Error\n    InterfaceError = InterfaceError\n    DatabaseError = DatabaseError\n    DataError = DataError\n    OperationalError = OperationalError\n    IntegrityError = IntegrityError\n    InternalError = InternalError\n    ProgrammingError = ProgrammingError\n    NotSupportedError = NotSupportedError\n   \n\nclass CursorStoreResultMixIn(object):\n\n    \"\"\"This is a MixIn class which causes the entire result set to be\n    stored on the client side, i.e. it uses mysql_store_result(). If the\n    result set can be very large, consider adding a LIMIT clause to your\n    query, or using CursorUseResultMixIn instead.\"\"\"\n\n    def _get_result(self): return self._get_db().store_result()\n\n    def _query(self, q):\n        rowcount = self._do_query(q)\n        self._post_get_result()\n        return rowcount\n\n    def _post_get_result(self):\n        self._rows = self._fetch_row(0)\n        self._result = None\n\n    def fetchone(self):\n        \"\"\"Fetches a single row from the cursor. None indicates that\n        no more rows are available.\"\"\"\n        self._check_executed()\n        if self.rownumber >= len(self._rows): return None\n        result = self._rows[self.rownumber]\n        self.rownumber = self.rownumber+1\n        return result\n\n    def fetchmany(self, size=None):\n        \"\"\"Fetch up to size rows from the cursor. Result set may be smaller\n        than size. If size is not defined, cursor.arraysize is used.\"\"\"\n        self._check_executed()\n        end = self.rownumber + (size or self.arraysize)\n        result = self._rows[self.rownumber:end]\n        self.rownumber = min(end, len(self._rows))\n        return result\n\n    def fetchall(self):\n        \"\"\"Fetchs all available rows from the cursor.\"\"\"\n        self._check_executed()\n        if self.rownumber:\n            result = self._rows[self.rownumber:]\n        else:\n            result = self._rows\n        self.rownumber = len(self._rows)\n        return result\n    \n    def scroll(self, value, mode='relative'):\n        \"\"\"Scroll the cursor in the result set to a new position according\n        to mode.\n        \n        If mode is 'relative' (default), value is taken as offset to\n        the current position in the result set, if set to 'absolute',\n        value states an absolute target position.\"\"\"\n        self._check_executed()\n        if mode == 'relative':\n            r = self.rownumber + value\n        elif mode == 'absolute':\n            r = value\n        else:\n            self.errorhandler(self, ProgrammingError,\n                              \"unknown scroll mode %s\" % repr(mode))\n        if r < 0 or r >= len(self._rows):\n            self.errorhandler(self, IndexError, \"out of range\")\n        self.rownumber = r\n\n    def __iter__(self):\n        self._check_executed()\n        result = self.rownumber and self._rows[self.rownumber:] or self._rows\n        return iter(result)\n    \n\nclass CursorUseResultMixIn(object):\n\n    \"\"\"This is a MixIn class which causes the result set to be stored\n    in the server and sent row-by-row to client side, i.e. it uses\n    mysql_use_result(). You MUST retrieve the entire result set and\n    close() the cursor before additional queries can be peformed on\n    the connection.\"\"\"\n\n    _defer_warnings = True\n    \n    def _get_result(self): return self._get_db().use_result()\n\n    def fetchone(self):\n        \"\"\"Fetches a single row from the cursor.\"\"\"\n        self._check_executed()\n        r = self._fetch_row(1)\n        if not r:\n            self._warning_check()\n            return None\n        self.rownumber = self.rownumber + 1\n        return r[0]\n             \n    def fetchmany(self, size=None):\n        \"\"\"Fetch up to size rows from the cursor. Result set may be smaller\n        than size. If size is not defined, cursor.arraysize is used.\"\"\"\n        self._check_executed()\n        r = self._fetch_row(size or self.arraysize)\n        self.rownumber = self.rownumber + len(r)\n        if not r:\n            self._warning_check()\n        return r\n         \n    def fetchall(self):\n        \"\"\"Fetchs all available rows from the cursor.\"\"\"\n        self._check_executed()\n        r = self._fetch_row(0)\n        self.rownumber = self.rownumber + len(r)\n        self._warning_check()\n        return r\n\n    def __iter__(self):\n        return self\n\n    def next(self):\n        row = self.fetchone()\n        if row is None:\n            raise StopIteration\n        return row\n    \n\nclass CursorTupleRowsMixIn(object):\n\n    \"\"\"This is a MixIn class that causes all rows to be returned as tuples,\n    which is the standard form required by DB API.\"\"\"\n\n    _fetch_type = 0\n\n\nclass CursorDictRowsMixIn(object):\n\n    \"\"\"This is a MixIn class that causes all rows to be returned as\n    dictionaries. This is a non-standard feature.\"\"\"\n\n    _fetch_type = 1\n\n    def fetchoneDict(self):\n        \"\"\"Fetch a single row as a dictionary. Deprecated:\n        Use fetchone() instead. Will be removed in 1.3.\"\"\"\n        from warnings import warn\n        warn(\"fetchoneDict() is non-standard and will be removed in 1.3\",\n             DeprecationWarning, 2)\n        return self.fetchone()\n\n    def fetchmanyDict(self, size=None):\n        \"\"\"Fetch several rows as a list of dictionaries. Deprecated:\n        Use fetchmany() instead. Will be removed in 1.3.\"\"\"\n        from warnings import warn\n        warn(\"fetchmanyDict() is non-standard and will be removed in 1.3\",\n             DeprecationWarning, 2)\n        return self.fetchmany(size)\n\n    def fetchallDict(self):\n        \"\"\"Fetch all available rows as a list of dictionaries. Deprecated:\n        Use fetchall() instead. Will be removed in 1.3.\"\"\"\n        from warnings import warn\n        warn(\"fetchallDict() is non-standard and will be removed in 1.3\",\n             DeprecationWarning, 2)\n        return self.fetchall()\n\n\nclass CursorOldDictRowsMixIn(CursorDictRowsMixIn):\n\n    \"\"\"This is a MixIn class that returns rows as dictionaries with\n    the same key convention as the old Mysqldb (MySQLmodule). Don't\n    use this.\"\"\"\n\n    _fetch_type = 2\n\n\nclass Cursor(CursorStoreResultMixIn, CursorTupleRowsMixIn,\n             BaseCursor):\n\n    \"\"\"This is the standard Cursor class that returns rows as tuples\n    and stores the result set in the client.\"\"\"\n\n\nclass DictCursor(CursorStoreResultMixIn, CursorDictRowsMixIn,\n                 BaseCursor):\n\n     \"\"\"This is a Cursor class that returns rows as dictionaries and\n    stores the result set in the client.\"\"\"\n   \n\nclass SSCursor(CursorUseResultMixIn, CursorTupleRowsMixIn,\n               BaseCursor):\n\n    \"\"\"This is a Cursor class that returns rows as tuples and stores\n    the result set in the server.\"\"\"\n\n\nclass SSDictCursor(CursorUseResultMixIn, CursorDictRowsMixIn,\n                   BaseCursor):\n\n    \"\"\"This is a Cursor class that returns rows as dictionaries and\n    stores the result set in the server.\"\"\"\n\n\n"
  },
  {
    "path": "MySQLdb/release.py",
    "content": "\r\n__author__ = \"Andy Dustman <farcepest@gmail.com>\"\r\nversion_info = (1,2,4,'final',1)\r\n__version__ = \"1.2.4\"\r\n"
  },
  {
    "path": "MySQLdb/times.py",
    "content": "\"\"\"times module\n\nThis module provides some Date and Time classes for dealing with MySQL data.\n\nUse Python datetime module to handle date and time columns.\"\"\"\n\nimport math\nfrom time import localtime\nfrom datetime import date, datetime, time, timedelta\nfrom _mysql import string_literal\n\nDate = date\nTime = time\nTimeDelta = timedelta\nTimestamp = datetime\n\nDateTimeDeltaType = timedelta\nDateTimeType = datetime\n\ndef DateFromTicks(ticks):\n    \"\"\"Convert UNIX ticks into a date instance.\"\"\"\n    return date(*localtime(ticks)[:3])\n\ndef TimeFromTicks(ticks):\n    \"\"\"Convert UNIX ticks into a time instance.\"\"\"\n    return time(*localtime(ticks)[3:6])\n\ndef TimestampFromTicks(ticks):\n    \"\"\"Convert UNIX ticks into a datetime instance.\"\"\"\n    return datetime(*localtime(ticks)[:6])\n\nformat_TIME = format_DATE = str\n\ndef format_TIMEDELTA(v):\n    seconds = int(v.seconds) % 60\n    minutes = int(v.seconds / 60) % 60\n    hours = int(v.seconds / 3600) % 24\n    return '%d %d:%d:%d' % (v.days, hours, minutes, seconds)\n\ndef format_TIMESTAMP(d):\n    return d.isoformat(\" \")\n\n\ndef DateTime_or_None(s):\n    if ' ' in s:\n        sep = ' '\n    elif 'T' in s:\n        sep = 'T'\n    else:\n        return Date_or_None(s)\n\n    try:\n        d, t = s.split(sep, 1)\n        if '.' in t:\n            t, ms = t.split('.',1)\n            ms = ms.ljust(6, '0')\n        else:\n            ms = 0\n        return datetime(*[ int(x) for x in d.split('-')+t.split(':')+[ms] ])\n    except (SystemExit, KeyboardInterrupt):\n        raise\n    except:\n        return Date_or_None(s)\n\ndef TimeDelta_or_None(s):\n    try:\n        h, m, s = s.split(':')\n        if '.' in s:\n            s, ms = s.split('.')\n            ms = ms.ljust(6, '0')\n        else:\n            ms = 0\n        h, m, s, ms = int(h), int(m), int(s), int(ms)\n        td = timedelta(hours=abs(h), minutes=m, seconds=s,\n                       microseconds=ms)\n        if h < 0:\n            return -td\n        else:\n            return td\n    except ValueError:\n        # unpacking or int/float conversion failed\n        return None\n\ndef Time_or_None(s):\n    try:\n        h, m, s = s.split(':')\n        if '.' in s:\n            s, ms = s.split('.')\n            ms = ms.ljust(6, '0')\n        else:\n            ms = 0\n        h, m, s, ms = int(h), int(m), int(s), int(ms)\n        return time(hour=h, minute=m, second=s,\n                    microsecond=ms)\n    except ValueError:\n        return None\n\ndef Date_or_None(s):\n    try:\n        return date(*[ int(x) for x in s.split('-',2)])\n    except (SystemExit, KeyboardInterrupt):\n        raise\n    except:\n        return None\n\ndef DateTime2literal(d, c):\n    \"\"\"Format a DateTime object as an ISO timestamp.\"\"\"\n    return string_literal(format_TIMESTAMP(d),c)\n    \ndef DateTimeDelta2literal(d, c):\n    \"\"\"Format a DateTimeDelta object as a time.\"\"\"\n    return string_literal(format_TIMEDELTA(d),c)\n\ndef mysql_timestamp_converter(s):\n    \"\"\"Convert a MySQL TIMESTAMP to a Timestamp object.\"\"\"\n    # MySQL>4.1 returns TIMESTAMP in the same format as DATETIME\n    if s[4] == '-': return DateTime_or_None(s)\n    s = s + \"0\"*(14-len(s)) # padding\n    parts = map(int, filter(None, (s[:4],s[4:6],s[6:8],\n                                   s[8:10],s[10:12],s[12:14])))\n    try:\n        return Timestamp(*parts)\n    except (SystemExit, KeyboardInterrupt):\n        raise\n    except:\n        return None\n"
  },
  {
    "path": "README.md",
    "content": "MySQLdb1\r\n========\r\n\r\nThis is the legacy (1.x) version of MySQLdb. While it is still being\r\nmaintained, there will not be a lot of new feature development. \r\n\r\n[![Build Status](https://secure.travis-ci.org/farcepest/MySQLdb1.png)](http://travis-ci.org/farcepest/MySQLdb1)\r\n\r\nTODO\r\n----\r\n\r\n* A bugfix 1.2.4 release\r\n* A 1.3.0 release that will support Python 2.7-3.3\r\n* The 2.0 version is being renamed [moist][] and is heavily refactored.\r\n\r\nProjects\r\n--------\r\n\r\n* [MySQLdb-svn][]\r\n\r\n\tThis is the old Subversion repository located on SourceForge.\r\n\tIt has all the early historical development of MySQLdb through 1.2.3,\r\n\tand also is the working repository for ZMySQLDA. The trunk on this\r\n\trepository was forked to create the [MySQLdb2][] repository.\r\n\r\n* [MySQLdb1][]\r\n\r\n\tThis is the new (active) git repository.\r\n\tOnly updates to the 1.x series will happen here.\r\n\r\n* [MySQLdb2][]\r\n\r\n\tThis is the now obsolete Mercurial repository for MySQLdb-2.0\r\n\tlocated on SourceForge. This repository has been migrated to the\r\n    [moist][] repository.\r\n\r\n\r\n[MySQLdb1]: https://github.com/farcepest/MySQLdb1\r\n[moist]: https://github.com/farcepest/moist\r\n[MySQLdb-svn]: https://sourceforge.net/p/mysql-python/svn/\r\n[MySQLdb2]: https://sourceforge.net/p/mysql-python/mysqldb-2/"
  },
  {
    "path": "_mysql.c",
    "content": "/*\nThis program is free software; you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation; either version 2, or (at your option)\nany later version. Alternatively, you may use the original license\nreproduced below.\n\nCopyright 1999 by Comstar.net, Inc., Atlanta, GA, US.\n\n                        All Rights Reserved\n\nPermission to use, copy, modify, and distribute this software and its\ndocumentation for any purpose and without fee is hereby granted,\nprovided that the above copyright notice appear in all copies and that\nboth that copyright notice and this permission notice appear in\nsupporting documentation, and that the name of Comstar.net, Inc.\nor COMSTAR not be used in advertising or publicity pertaining to\ndistribution of the software without specific, written prior permission.\n\nCOMSTAR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,\nINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO\nEVENT SHALL COMSTAR BE LIABLE FOR ANY SPECIAL, INDIRECT OR\nCONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF\nUSE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n*/\n\n#include \"Python.h\"\n#if PY_MAJOR_VERSION >= 3\n#define IS_PY3K\n#define PyInt_FromLong(n) PyLong_FromLong(n)\n#define PyInt_Check(n) PyLong_Check(n)\n#define PyInt_AS_LONG(n) PyLong_AS_LONG(n)\n#endif\n#if PY_VERSION_HEX > 0x02060000\n#include \"bytesobject.h\"\n#endif\n#include \"pymemcompat.h\"\n#include \"structmember.h\"\n#if defined(MS_WINDOWS)\n#include <config-win.h>\n#else\n#include \"my_config.h\"\n#endif\n#include \"mysql.h\"\n#include \"mysqld_error.h\"\n#include \"errmsg.h\"\n\n#if PY_VERSION_HEX < 0x02020000\n# define MyTuple_Resize(t,n,d) _PyTuple_Resize(t, n, d)\n# define MyMember(a,b,c,d,e) {a,b,c,d}\n# define MyMemberlist(x) struct memberlist x\n# define MyAlloc(s,t) PyObject_New(s,&t)\n# define MyFree(o) PyObject_Del(o)\n#else\n# define MyTuple_Resize(t,n,d) _PyTuple_Resize(t, n)\n# define MyMember(a,b,c,d,e) {a,b,c,d,e}\n# define MyMemberlist(x) struct PyMemberDef x\n# define MyAlloc(s,t) (s *) t.tp_alloc(&t,0)\n#ifdef IS_PY3K\n# define MyFree(o) PyObject_Del(o)\n#else\n# define MyFree(ob) ob->ob_type->tp_free((PyObject *)ob)\n#endif\n#endif\n\n#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)\ntypedef int Py_ssize_t;\n#define PY_SSIZE_T_MAX INT_MAX\n#define PY_SSIZE_T_MIN INT_MIN\n#endif\n\nstatic PyObject *_mysql_MySQLError;\nstatic PyObject *_mysql_Warning;\nstatic PyObject *_mysql_Error;\nstatic PyObject *_mysql_DatabaseError;\nstatic PyObject *_mysql_InterfaceError; \nstatic PyObject *_mysql_DataError;\nstatic PyObject *_mysql_OperationalError; \nstatic PyObject *_mysql_IntegrityError; \nstatic PyObject *_mysql_InternalError; \nstatic PyObject *_mysql_ProgrammingError;\nstatic PyObject *_mysql_NotSupportedError;\n \ntypedef struct {\n\tPyObject_HEAD\n\tMYSQL connection;\n\tint open;\n\tPyObject *converter;\n} _mysql_ConnectionObject;\n\n#define check_connection(c) if (!(c->open)) return _mysql_Exception(c)\n#define result_connection(r) ((_mysql_ConnectionObject *)r->conn)\n#define check_result_connection(r) check_connection(result_connection(r))\n\nextern PyTypeObject _mysql_ConnectionObject_Type;\n\ntypedef struct {\n\tPyObject_HEAD\n\tPyObject *conn;\n\tMYSQL_RES *result;\n\tint nfields;\n\tint use;\n\tPyObject *converter;\n} _mysql_ResultObject;\n\nextern PyTypeObject _mysql_ResultObject_Type;\n\nstatic int _mysql_server_init_done = 0;\n#if MYSQL_VERSION_ID >= 40000\n#define check_server_init(x) if (!_mysql_server_init_done) { if (mysql_server_init(0, NULL, NULL)) { _mysql_Exception(NULL); return x; } else { _mysql_server_init_done = 1;} }\n#else\n#define check_server_init(x) if (!_mysql_server_init_done) _mysql_server_init_done = 1\n#endif\n\n#if MYSQL_VERSION_ID >= 50500\n#define HAVE_OPENSSL 1\n#endif\n\n/* According to https://dev.mysql.com/doc/refman/5.1/en/mysql-options.html\n   The MYSQL_OPT_READ_TIMEOUT apear in the version 5.1.12 */\n#if MYSQL_VERSION_ID > 50112\n#define HAVE_MYSQL_OPT_TIMEOUTS 1\n#endif\n\nPyObject *\n_mysql_Exception(_mysql_ConnectionObject *c)\n{\n\tPyObject *t, *e;\n\tint merr;\n\n\tif (!(t = PyTuple_New(2))) return NULL;\n\tif (!_mysql_server_init_done) {\n\t\te = _mysql_InternalError;\n\t\tPyTuple_SET_ITEM(t, 0, PyInt_FromLong(-1L));\n#ifdef IS_PY3K\n\t\tPyTuple_SET_ITEM(t, 1, PyUnicode_FromString(\"server not initialized\"));\n#else\n\t\tPyTuple_SET_ITEM(t, 1, PyString_FromString(\"server not initialized\"));\n#endif\n\t\tPyErr_SetObject(e, t);\n\t\tPy_DECREF(t);\n\t\treturn NULL;\n\t}\n\tmerr = mysql_errno(&(c->connection));\n\tif (!merr)\n\t\te = _mysql_InterfaceError;\n\telse if (merr > CR_MAX_ERROR) {\n\t\tPyTuple_SET_ITEM(t, 0, PyInt_FromLong(-1L));\n#ifdef IS_PY3K\n\t\tPyTuple_SET_ITEM(t, 1, PyUnicode_FromString(\"error totally whack\"));\n#else\n\t\tPyTuple_SET_ITEM(t, 1, PyString_FromString(\"error totally whack\"));\n#endif\n\t\tPyErr_SetObject(_mysql_InterfaceError, t);\n\t\tPy_DECREF(t);\n\t\treturn NULL;\n\t}\n\telse switch (merr) {\n\tcase CR_COMMANDS_OUT_OF_SYNC:\n\tcase ER_DB_CREATE_EXISTS:\n\tcase ER_SYNTAX_ERROR:\n\tcase ER_PARSE_ERROR:\n\tcase ER_NO_SUCH_TABLE:\n\tcase ER_WRONG_DB_NAME:\n\tcase ER_WRONG_TABLE_NAME:\n\tcase ER_FIELD_SPECIFIED_TWICE:\n\tcase ER_INVALID_GROUP_FUNC_USE:\n\tcase ER_UNSUPPORTED_EXTENSION:\n\tcase ER_TABLE_MUST_HAVE_COLUMNS:\n#ifdef ER_CANT_DO_THIS_DURING_AN_TRANSACTION\n\tcase ER_CANT_DO_THIS_DURING_AN_TRANSACTION:\n#endif\n\t\te = _mysql_ProgrammingError;\n\t\tbreak;\n#ifdef WARN_DATA_TRUNCATED\n\tcase WARN_DATA_TRUNCATED:\n#ifdef WARN_NULL_TO_NOTNULL\n\tcase WARN_NULL_TO_NOTNULL:\n#endif\n#ifdef ER_WARN_DATA_OUT_OF_RANGE\n\tcase ER_WARN_DATA_OUT_OF_RANGE:\n#endif\n#ifdef ER_NO_DEFAULT\n\tcase ER_NO_DEFAULT:\n#endif\n#ifdef ER_PRIMARY_CANT_HAVE_NULL\n\tcase ER_PRIMARY_CANT_HAVE_NULL:\n#endif\n#ifdef ER_DATA_TOO_LONG\n\tcase ER_DATA_TOO_LONG:\n#endif\n#ifdef ER_DATETIME_FUNCTION_OVERFLOW\n\tcase ER_DATETIME_FUNCTION_OVERFLOW:\n#endif\n\t\te = _mysql_DataError;\n\t\tbreak;\n#endif\n\tcase ER_DUP_ENTRY:\n#ifdef ER_DUP_UNIQUE\n\tcase ER_DUP_UNIQUE:\n#endif\n#ifdef ER_NO_REFERENCED_ROW\n\tcase ER_NO_REFERENCED_ROW:\n#endif\n#ifdef ER_NO_REFERENCED_ROW_2\n\tcase ER_NO_REFERENCED_ROW_2:\n#endif\n#ifdef ER_ROW_IS_REFERENCED\n\tcase ER_ROW_IS_REFERENCED:\n#endif\n#ifdef ER_ROW_IS_REFERENCED_2\n\tcase ER_ROW_IS_REFERENCED_2:\n#endif\n#ifdef ER_CANNOT_ADD_FOREIGN\n\tcase ER_CANNOT_ADD_FOREIGN:\n#endif\n\t\te = _mysql_IntegrityError;\n\t\tbreak;\n#ifdef ER_WARNING_NOT_COMPLETE_ROLLBACK\n\tcase ER_WARNING_NOT_COMPLETE_ROLLBACK:\n#endif\n#ifdef ER_NOT_SUPPORTED_YET\n\tcase ER_NOT_SUPPORTED_YET:\n#endif\n#ifdef ER_FEATURE_DISABLED\n\tcase ER_FEATURE_DISABLED:\n#endif\n#ifdef ER_UNKNOWN_STORAGE_ENGINE\n\tcase ER_UNKNOWN_STORAGE_ENGINE:\n#endif\n\t\te = _mysql_NotSupportedError;\n\t\tbreak;\n\tdefault:\n\t\tif (merr < 1000)\n\t\t\te = _mysql_InternalError;\n\t\telse\n\t\t\te = _mysql_OperationalError;\n\t\tbreak;\n\t}\n\tPyTuple_SET_ITEM(t, 0, PyInt_FromLong((long)merr));\n#ifdef IS_PY3K\n\tPyTuple_SET_ITEM(t, 1, PyUnicode_FromString(mysql_error(&(c->connection))));\n#else\n\tPyTuple_SET_ITEM(t, 1, PyString_FromString(mysql_error(&(c->connection))));\n#endif\n\tPyErr_SetObject(e, t);\n\tPy_DECREF(t);\n\treturn NULL;\n}\n\t  \nstatic char _mysql_server_init__doc__[] =\n\"Initialize embedded server. If this client is not linked against\\n\\\nthe embedded server library, this function does nothing.\\n\\\n\\n\\\nargs -- sequence of command-line arguments\\n\\\ngroups -- sequence of groups to use in defaults files\\n\\\n\";\n\nstatic PyObject *_mysql_server_init(\n\tPyObject *self,\n\tPyObject *args,\n\tPyObject *kwargs) {\n\tstatic char *kwlist[] = {\"args\", \"groups\", NULL};\n\tchar **cmd_args_c=NULL, **groups_c=NULL, *s;\n\tint cmd_argc=0, i, groupc;\n\tPyObject *cmd_args=NULL, *groups=NULL, *ret=NULL, *item;\n\n\tif (_mysql_server_init_done) {\n\t\tPyErr_SetString(_mysql_ProgrammingError,\n\t\t\t\t\"already initialized\");\n\t\treturn NULL;\n\t}\n\t  \n\tif (!PyArg_ParseTupleAndKeywords(args, kwargs, \"|OO\", kwlist,\n\t\t\t\t\t &cmd_args, &groups))\n\t\treturn NULL;\n\n#if MYSQL_VERSION_ID >= 40000\n\tif (cmd_args) {\n\t\tif (!PySequence_Check(cmd_args)) {\n\t\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\t\"args must be a sequence\");\n\t\t\tgoto finish;\n\t\t}\n\t\tcmd_argc = PySequence_Size(cmd_args);\n\t\tif (cmd_argc == -1) {\n\t\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\t\"args could not be sized\");\n\t\t\tgoto finish;\n\t\t}\n\t\tcmd_args_c = (char **) PyMem_Malloc(cmd_argc*sizeof(char *));\n\t\tfor (i=0; i< cmd_argc; i++) {\n\t\t\titem = PySequence_GetItem(cmd_args, i);\n#ifdef IS_PY3K\n\t\t\ts = PyUnicode_AS_DATA(item);\n#else\n\t\t\ts = PyString_AsString(item);\n#endif\n\n\t\t\tPy_DECREF(item);\n\t\t\tif (!s) {\n\t\t\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\t\t\"args must contain strings\");\n\t\t\t\tgoto finish;\n\t\t\t}\n\t\t\tcmd_args_c[i] = s;\n\t\t}\n\t}\n\tif (groups) {\n\t\tif (!PySequence_Check(groups)) {\n\t\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\t\"groups must be a sequence\");\n\t\t\tgoto finish;\n\t\t}\n\t\tgroupc = PySequence_Size(groups);\n\t\tif (groupc == -1) {\n\t\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\t\"groups could not be sized\");\n\t\t\tgoto finish;\n\t\t}\n\t\tgroups_c = (char **) PyMem_Malloc((1+groupc)*sizeof(char *));\n\t\tfor (i=0; i< groupc; i++) {\n\t\t\titem = PySequence_GetItem(groups, i);\n#ifdef IS_PY3K\n\t\t\ts = PyUnicode_AS_DATA(item);\n#else\n\t\t\ts = PyString_AsString(item);\n#endif\n\t\t\tPy_DECREF(item);\n\t\t\tif (!s) {\n\t\t\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\t\t\"groups must contain strings\");\n\t\t\t\tgoto finish;\n\t\t\t}\n\t\t\tgroups_c[i] = s;\n\t\t}\n\t\tgroups_c[groupc] = (char *)NULL;\n\t}\n\t/* even though this may block, don't give up the interpreter lock\n\t   so that the server can't be initialized multiple times. */\n\tif (mysql_server_init(cmd_argc, cmd_args_c, groups_c)) {\n\t\t_mysql_Exception(NULL);\n\t\tgoto finish;\n\t}\n#endif\n\tret = Py_None;\n\tPy_INCREF(Py_None);\n\t_mysql_server_init_done = 1;\n  finish:\n\tPyMem_Free(groups_c);\n\tPyMem_Free(cmd_args_c);\n\treturn ret;\n}\n\nstatic char _mysql_server_end__doc__[] =\n\"Shut down embedded server. If not using an embedded server, this\\n\\\ndoes nothing.\";\n\nstatic PyObject *_mysql_server_end(\n\tPyObject *self,\n\tPyObject *args) {\n\tif (_mysql_server_init_done) {\n#if MYSQL_VERSION_ID >= 40000\n\t\tmysql_server_end();\n#endif\n\t\t_mysql_server_init_done = 0;\n\t\tPy_INCREF(Py_None);\n\t\treturn Py_None;\n\t}\n\treturn _mysql_Exception(NULL);\n}\n\t \n#if MYSQL_VERSION_ID >= 32314\nstatic char _mysql_thread_safe__doc__[] =\n\"Indicates whether the client is compiled as thread-safe.\";\n\nstatic PyObject *_mysql_thread_safe(\n\tPyObject *self,\n\tPyObject *args) {\n\tPyObject *flag;\n\tif (!PyArg_ParseTuple(args, \"\")) return NULL;\n\tcheck_server_init(NULL);\n\tif (!(flag=PyInt_FromLong((long)mysql_thread_safe()))) return NULL;\n\treturn flag;\n}\n#endif\n\nstatic char _mysql_ResultObject__doc__[] =\n\"result(connection, use=0, converter={}) -- Result set from a query.\\n\\\n\\n\\\nCreating instances of this class directly is an excellent way to\\n\\\nshoot yourself in the foot. If using _mysql.connection directly,\\n\\\nuse connection.store_result() or connection.use_result() instead.\\n\\\nIf using MySQLdb.Connection, this is done by the cursor class.\\n\\\nJust forget you ever saw this. Forget... FOR-GET...\";\n\nstatic int\n_mysql_ResultObject_Initialize(\n\t_mysql_ResultObject *self,\n\tPyObject *args,\n\tPyObject *kwargs)\n{\n\tstatic char *kwlist[] = {\"connection\", \"use\", \"converter\", NULL};\n\tMYSQL_RES *result; \n\t_mysql_ConnectionObject *conn=NULL;\n\tint use=0; \n\tPyObject *conv=NULL;\n\tint n, i;\n\tMYSQL_FIELD *fields;\n\n\tif (!PyArg_ParseTupleAndKeywords(args, kwargs, \"O|iO\", kwlist,\n\t\t\t\t\t  &conn, &use, &conv))\n\t\treturn -1;\n\tif (!conv) {\n\t\tif (!(conv = PyDict_New()))\n\t\t\treturn -1;\n\t}\n\telse\n\t\tPy_INCREF(conv);\n\n\tself->conn = (PyObject *) conn;\n\tPy_INCREF(conn);\n\tself->use = use;\n\tPy_BEGIN_ALLOW_THREADS ;\n\tif (use)\n\t\tresult = mysql_use_result(&(conn->connection));\n\telse\n\t\tresult = mysql_store_result(&(conn->connection));\n\tself->result = result;\n\tPy_END_ALLOW_THREADS ;\n\tif (!result) {\n\t\tif (mysql_field_count(&(conn->connection)) > 0) {\n\t\t    _mysql_Exception(conn);\n\t\t    return -1;\n\t\t}\n\t\tself->converter = PyTuple_New(0);\n\t\tPy_DECREF(conv);\n\t\treturn 0;\n\t}\n\tn = mysql_num_fields(result);\n\tself->nfields = n;\n\tif (!(self->converter = PyTuple_New(n))) {\n\t\tPy_DECREF(conv);\n\t\treturn -1;\n\t}\n\tfields = mysql_fetch_fields(result);\n\tfor (i=0; i<n; i++) {\n\t\tPyObject *tmp, *fun;\n\t\ttmp = PyInt_FromLong((long) fields[i].type);\n\t\tif (!tmp) {\n\t\t\tPy_DECREF(conv);\n\t\t\treturn -1;\n\t\t}\n\t\tfun = PyObject_GetItem(conv, tmp);\n\t\tPy_DECREF(tmp);\n\t\tif (!fun) {\n\t\t\tif (PyErr_Occurred()) {\n\t\t\t\tif (!PyErr_ExceptionMatches(PyExc_KeyError)) {\n\t\t\t\t\tPy_DECREF(conv);\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\t\t\t\tPyErr_Clear();\n\t\t\t}\n\t\t\tfun = Py_None;\n\t\t\tPy_INCREF(Py_None);\n\t\t}\n\t\telse if (PySequence_Check(fun)) {\n\t\t\tint j, n2=PySequence_Size(fun);\n\t\t\tPyObject *fun2=NULL;\n\t\t\tfor (j=0; j<n2; j++) {\n\t\t\t\tPyObject *t = PySequence_GetItem(fun, j);\n\t\t\t\tif (!t) {\n\t\t\t\t\tPy_DECREF(fun);\n\t\t\t\t\tPy_DECREF(conv);\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\t\t\t\tif (PyTuple_Check(t) && PyTuple_GET_SIZE(t) == 2) {\n\t\t\t\t\tlong mask, flags;\n\t\t\t\t\tPyObject *pmask=NULL;\n\t\t\t\t\tpmask = PyTuple_GET_ITEM(t, 0);\n\t\t\t\t\tfun2 = PyTuple_GET_ITEM(t, 1);\n\t\t\t\t\tPy_XINCREF(fun2);\n\t\t\t\t\tif (PyInt_Check(pmask)) {\n\t\t\t\t\t\tmask = PyInt_AS_LONG(pmask);\n\t\t\t\t\t\tflags = fields[i].flags;\n\t\t\t\t\t\tif (fields[i].charsetnr != 63) { /* maaagic */\n\t\t\t\t\t\t\tflags &= ~BINARY_FLAG;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (mask & flags) {\n\t\t\t\t\t\t\tPy_DECREF(t);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tfun2 = NULL;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tPy_DECREF(t);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tPy_DECREF(t);\n\t\t\t}\n\t\t\tif (!fun2) {\n\t\t\t\tfun2 = Py_None;\n\t\t\t\tPy_INCREF(fun2);\n\t\t\t}\n\t\t\tPy_DECREF(fun);\n\t\t\tfun = fun2;\n\t\t}\n\t\tPyTuple_SET_ITEM(self->converter, i, fun);\n\t}\n\n\tPy_DECREF(conv);\n\treturn 0;\n}\n\n#if PY_VERSION_HEX >= 0x02020000\nstatic int _mysql_ResultObject_traverse(\n\t_mysql_ResultObject *self,\n\tvisitproc visit,\n\tvoid *arg)\n{\n\tint r;\n\tif (self->converter) {\n\t\tif (!(r = visit(self->converter, arg))) return r;\n\t}\n\tif (self->conn)\n\t\treturn visit(self->conn, arg);\n\treturn 0;\n}\n#endif\n\nstatic int _mysql_ResultObject_clear(\n\t_mysql_ResultObject *self)\n{\n\tPy_XDECREF(self->converter);\n\tself->converter = NULL;\n\tPy_XDECREF(self->conn);\n\tself->conn = NULL;\n\treturn 0;\n}\n\nstatic int\n_mysql_ConnectionObject_Initialize(\n\t_mysql_ConnectionObject *self,\n\tPyObject *args,\n\tPyObject *kwargs)\n{\n\tMYSQL *conn = NULL;\n\tPyObject *conv = NULL;\n\tPyObject *ssl = NULL;\n#if HAVE_OPENSSL\n\tchar *key = NULL, *cert = NULL, *ca = NULL,\n\t\t*capath = NULL, *cipher = NULL;\n#endif\n\tchar *host = NULL, *user = NULL, *passwd = NULL,\n\t\t*db = NULL, *unix_socket = NULL;\n\tunsigned int port = 0;\n\tunsigned int client_flag = 0;\n\tstatic char *kwlist[] = { \"host\", \"user\", \"passwd\", \"db\", \"port\",\n\t\t\t\t  \"unix_socket\", \"conv\",\n\t\t\t\t  \"connect_timeout\", \"compress\",\n\t\t\t\t  \"named_pipe\", \"init_command\",\n\t\t\t\t  \"read_default_file\", \"read_default_group\",\n\t\t\t\t  \"client_flag\", \"ssl\",\n\t\t\t\t  \"local_infile\",\n#ifdef HAVE_MYSQL_OPT_TIMEOUTS\n                                  \"read_timeout\",\n                                  \"write_timeout\",\n#endif\n\t\t\t\t  NULL } ;\n\tint connect_timeout = 0;\n#ifdef HAVE_MYSQL_OPT_TIMEOUTS\n        int read_timeout = 0;\n        int write_timeout = 0;\n#endif\n\tint compress = -1, named_pipe = -1, local_infile = -1;\n\tchar *init_command=NULL,\n\t     *read_default_file=NULL,\n\t     *read_default_group=NULL;\n\t\n\tself->converter = NULL;\n\tself->open = 0;\n\tcheck_server_init(-1);\n\n\tif (!PyArg_ParseTupleAndKeywords(args, kwargs,\n#ifdef HAVE_MYSQL_OPT_TIMEOUTS\n                                         \"|ssssisOiiisssiOiii:connect\",\n#else\n                                         \"|ssssisOiiisssiOi:connect\",\n#endif\n\t\t\t\t\t kwlist,\n\t\t\t\t\t &host, &user, &passwd, &db,\n\t\t\t\t\t &port, &unix_socket, &conv,\n\t\t\t\t\t &connect_timeout,\n\t\t\t\t\t &compress, &named_pipe,\n\t\t\t\t\t &init_command, &read_default_file,\n\t\t\t\t\t &read_default_group,\n\t\t\t\t\t &client_flag, &ssl,\n                     &local_infile\n#ifdef HAVE_MYSQL_OPT_TIMEOUTS\n                     , &read_timeout\n                     , &write_timeout\n#endif\n\t))\n\t\treturn -1;\n\n#ifdef IS_PY3K\n#define _stringsuck(d,t,s) {t=PyMapping_GetItemString(s,#d);\\\n        if(t){d=PyUnicode_AS_DATA(t);Py_DECREF(t);}\\\n        PyErr_Clear();}\n#else\n#define _stringsuck(d,t,s) {t=PyMapping_GetItemString(s,#d);\\\n        if(t){d=PyString_AsString(t);Py_DECREF(t);}\\\n        PyErr_Clear();}\n#endif\n\n\tif (ssl) {\n#if HAVE_OPENSSL\n\t\tPyObject *value = NULL;\n\t\t_stringsuck(ca, value, ssl);\n\t\t_stringsuck(capath, value, ssl);\n\t\t_stringsuck(cert, value, ssl);\n\t\t_stringsuck(key, value, ssl);\n\t\t_stringsuck(cipher, value, ssl);\n#else\n\t\tPyErr_SetString(_mysql_NotSupportedError,\n\t\t\t\t\"client library does not have SSL support\");\n\t\treturn -1;\n#endif\n\t}\n\n\tPy_BEGIN_ALLOW_THREADS ;\n\tconn = mysql_init(&(self->connection));\n\tif (connect_timeout) {\n\t\tunsigned int timeout = connect_timeout;\n\t\tmysql_options(&(self->connection), MYSQL_OPT_CONNECT_TIMEOUT, \n\t\t\t\t(char *)&timeout);\n\t}\n#ifdef HAVE_MYSQL_OPT_TIMEOUTS\n\tif (read_timeout) {\n\t\tunsigned int timeout = read_timeout;\n\t\tmysql_options(&(self->connection), MYSQL_OPT_READ_TIMEOUT,\n\t\t\t\t(char *)&timeout);\n\t}\n\tif (write_timeout) {\n\t\tunsigned int timeout = write_timeout;\n\t\tmysql_options(&(self->connection), MYSQL_OPT_WRITE_TIMEOUT,\n\t\t\t\t(char *)&timeout);\n\t}\n#endif\n\tif (compress != -1) {\n\t\tmysql_options(&(self->connection), MYSQL_OPT_COMPRESS, 0);\n\t\tclient_flag |= CLIENT_COMPRESS;\n\t}\n\tif (named_pipe != -1)\n\t\tmysql_options(&(self->connection), MYSQL_OPT_NAMED_PIPE, 0);\n\tif (init_command != NULL)\n\t\tmysql_options(&(self->connection), MYSQL_INIT_COMMAND, init_command);\n\tif (read_default_file != NULL)\n\t\tmysql_options(&(self->connection), MYSQL_READ_DEFAULT_FILE, read_default_file);\n\tif (read_default_group != NULL)\n\t\tmysql_options(&(self->connection), MYSQL_READ_DEFAULT_GROUP, read_default_group);\n\n\tif (local_infile != -1)\n\t\tmysql_options(&(self->connection), MYSQL_OPT_LOCAL_INFILE, (char *) &local_infile);\n\n#if HAVE_OPENSSL\n\tif (ssl)\n\t\tmysql_ssl_set(&(self->connection),\n\t\t\t      key, cert, ca, capath, cipher);\n#endif\n\n\tconn = mysql_real_connect(&(self->connection), host, user, passwd, db,\n\t\t\t\t  port, unix_socket, client_flag);\n\n\tPy_END_ALLOW_THREADS ;\n\n\tif (!conn) {\n\t\t_mysql_Exception(self);\n\t\treturn -1;\n\t}\n\n        /* Internal references to python-land objects */\n\tif (!conv)\n\t\tconv = PyDict_New();\n\telse\n\t\tPy_INCREF(conv);\n\n\tif (!conv)\n\t\treturn -1;\n\tself->converter = conv;\n\n\t/*\n\t  PyType_GenericAlloc() automatically sets up GC allocation and\n\t  tracking for GC objects, at least in 2.2.1, so it does not need to\n\t  be done here. tp_dealloc still needs to call PyObject_GC_UnTrack(),\n\t  however.\n\t*/\n\tself->open = 1;\n\treturn 0;\n}\n\nstatic char _mysql_connect__doc__[] =\n\"Returns a MYSQL connection object. Exclusive use of\\n\\\nkeyword parameters strongly recommended. Consult the\\n\\\nMySQL C API documentation for more details.\\n\\\n\\n\\\nhost\\n\\\n  string, host to connect\\n\\\n\\n\\\nuser\\n\\\n  string, user to connect as\\n\\\n\\n\\\npasswd\\n\\\n  string, password to use\\n\\\n\\n\\\ndb\\n\\\n  string, database to use\\n\\\n\\n\\\nport\\n\\\n  integer, TCP/IP port to connect to\\n\\\n\\n\\\nunix_socket\\n\\\n  string, location of unix_socket (UNIX-ish only)\\n\\\n\\n\\\nconv\\n\\\n  mapping, maps MySQL FIELD_TYPE.* to Python functions which\\n\\\n  convert a string to the appropriate Python type\\n\\\n\\n\\\nconnect_timeout\\n\\\n  number of seconds to wait before the connection\\n\\\n  attempt fails.\\n\\\n\\n\\\ncompress\\n\\\n  if set, gzip compression is enabled\\n\\\n\\n\\\nnamed_pipe\\n\\\n  if set, connect to server via named pipe (Windows only)\\n\\\n\\n\\\ninit_command\\n\\\n  command which is run once the connection is created\\n\\\n\\n\\\nread_default_file\\n\\\n  see the MySQL documentation for mysql_options()\\n\\\n\\n\\\nread_default_group\\n\\\n  see the MySQL documentation for mysql_options()\\n\\\n\\n\\\nclient_flag\\n\\\n  client flags from MySQLdb.constants.CLIENT\\n\\\n\\n\\\nload_infile\\n\\\n  int, non-zero enables LOAD LOCAL INFILE, zero disables\\n\\\n\\n\\\n\";\n\nstatic PyObject *\n_mysql_connect(\n\tPyObject *self,\n\tPyObject *args,\n\tPyObject *kwargs)\n{\n\t_mysql_ConnectionObject *c=NULL;\n\t\n\tc = MyAlloc(_mysql_ConnectionObject, _mysql_ConnectionObject_Type);\n\tif (c == NULL) return NULL;\n\tif (_mysql_ConnectionObject_Initialize(c, args, kwargs)) {\n\t\tPy_DECREF(c);\n\t\tc = NULL;\n\t}\n\treturn (PyObject *) c;\n}\n\n#if PY_VERSION_HEX >= 0x02020000\nstatic int _mysql_ConnectionObject_traverse(\n\t_mysql_ConnectionObject *self,\n\tvisitproc visit,\n\tvoid *arg)\n{\n\tif (self->converter)\n\t\treturn visit(self->converter, arg);\n\treturn 0;\n}\n#endif\n\nstatic int _mysql_ConnectionObject_clear(\n\t_mysql_ConnectionObject *self)\n{\n\tPy_XDECREF(self->converter);\n\tself->converter = NULL;\n\treturn 0;\n}\n\nstatic char _mysql_ConnectionObject_close__doc__[] =\n\"Close the connection. No further activity possible.\";\n\nstatic PyObject *\n_mysql_ConnectionObject_close(\n\t_mysql_ConnectionObject *self,\n\tPyObject *args)\n{\n\tif (args) {\n\t\tif (!PyArg_ParseTuple(args, \"\")) return NULL;\n\t}\n\tif (self->open) {\n\t\tPy_BEGIN_ALLOW_THREADS\n\t\tmysql_close(&(self->connection));\n\t\tPy_END_ALLOW_THREADS\n\t\tself->open = 0;\n\t} else {\n\t\tPyErr_SetString(_mysql_ProgrammingError,\n\t\t\t\t\"closing a closed connection\");\n\t\treturn NULL;\n\t}\n\t_mysql_ConnectionObject_clear(self);\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic char _mysql_ConnectionObject_affected_rows__doc__ [] =\n\"Return number of rows affected by the last query.\\n\\\nNon-standard. Use Cursor.rowcount.\\n\\\n\";\n\nstatic PyObject *\n_mysql_ConnectionObject_affected_rows(\n\t_mysql_ConnectionObject *self,\n\tPyObject *args)\n{\n\tif (!PyArg_ParseTuple(args, \"\")) return NULL;\n\tcheck_connection(self);\n\treturn PyLong_FromUnsignedLongLong(mysql_affected_rows(&(self->connection)));\n}\n\nstatic char _mysql_debug__doc__[] =\n\"Does a DBUG_PUSH with the given string.\\n\\\nmysql_debug() uses the Fred Fish debug library.\\n\\\nTo use this function, you must compile the client library to\\n\\\nsupport debugging.\\n\\\n\";\nstatic PyObject *\n_mysql_debug(\n\tPyObject *self,\n\tPyObject *args)\n{\n\tchar *debug;\n\tif (!PyArg_ParseTuple(args, \"s\", &debug)) return NULL;\n\tmysql_debug(debug);\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic char _mysql_ConnectionObject_dump_debug_info__doc__[] =\n\"Instructs the server to write some debug information to the\\n\\\nlog. The connected user must have the process privilege for\\n\\\nthis to work. Non-standard.\\n\\\n\";\n\nstatic PyObject *\n_mysql_ConnectionObject_dump_debug_info(\n\t_mysql_ConnectionObject *self,\n\tPyObject *args)\n{\n\tint err;\n\tif (!PyArg_ParseTuple(args, \"\")) return NULL;\n\tcheck_connection(self);\n\tPy_BEGIN_ALLOW_THREADS\n\terr = mysql_dump_debug_info(&(self->connection));\n\tPy_END_ALLOW_THREADS\n\tif (err) return _mysql_Exception(self);\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic char _mysql_ConnectionObject_autocommit__doc__[] =\n\"Set the autocommit mode. True values enable; False value disable.\\n\\\n\";\nstatic PyObject *\n_mysql_ConnectionObject_autocommit(\n\t_mysql_ConnectionObject *self,\n\tPyObject *args)\n{\n\tint flag, err;\n\tif (!PyArg_ParseTuple(args, \"i\", &flag)) return NULL;\n\tPy_BEGIN_ALLOW_THREADS\n#if MYSQL_VERSION_ID >= 40100\n\terr = mysql_autocommit(&(self->connection), flag);\n#else\n\t{\n\t\tchar query[256];\n\t\tsnprintf(query, 256, \"SET AUTOCOMMIT=%d\", flag);\n\t\terr = mysql_query(&(self->connection), query);\n\t}\n#endif\n\tPy_END_ALLOW_THREADS\n\tif (err) return _mysql_Exception(self);\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic char _mysql_ConnectionObject_get_autocommit__doc__[] =\n\"Get the autocommit mode. True when enable; False when disable.\\n\";\n\nstatic PyObject *\n_mysql_ConnectionObject_get_autocommit(\n\t_mysql_ConnectionObject *self,\n\tPyObject *args)\n{\n\tif (self->connection.server_status & SERVER_STATUS_AUTOCOMMIT) {\n\t\tPy_RETURN_TRUE;\n\t}\n\tPy_RETURN_FALSE;\n}\n\nstatic char _mysql_ConnectionObject_commit__doc__[] =\n\"Commits the current transaction\\n\\\n\";\nstatic PyObject *\n_mysql_ConnectionObject_commit(\n\t_mysql_ConnectionObject *self,\n\tPyObject *args)\n{\n\tint err;\n\tif (!PyArg_ParseTuple(args, \"\")) return NULL;\n\tPy_BEGIN_ALLOW_THREADS\n#if MYSQL_VERSION_ID >= 40100\n\terr = mysql_commit(&(self->connection));\n#else\n\terr = mysql_query(&(self->connection), \"COMMIT\");\n#endif\n\tPy_END_ALLOW_THREADS\n\tif (err) return _mysql_Exception(self);\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\t\t\n\nstatic char _mysql_ConnectionObject_rollback__doc__[] =\n\"Rolls backs the current transaction\\n\\\n\";\nstatic PyObject *\n_mysql_ConnectionObject_rollback(\n\t_mysql_ConnectionObject *self,\n\tPyObject *args)\n{\n\tint err;\n\tif (!PyArg_ParseTuple(args, \"\")) return NULL;\n\tPy_BEGIN_ALLOW_THREADS\n#if MYSQL_VERSION_ID >= 40100\n\terr = mysql_rollback(&(self->connection));\n#else\n\terr = mysql_query(&(self->connection), \"ROLLBACK\");\n#endif\n\tPy_END_ALLOW_THREADS\n\tif (err) return _mysql_Exception(self);\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\t\t\n\nstatic char _mysql_ConnectionObject_next_result__doc__[] =\n\"If more query results exist, next_result() reads the next query\\n\\\nresults and returns the status back to application.\\n\\\n\\n\\\nAfter calling next_result() the state of the connection is as if\\n\\\nyou had called query() for the next query. This means that you can\\n\\\nnow call store_result(), warning_count(), affected_rows()\\n\\\n, and so forth. \\n\\\n\\n\\\nReturns 0 if there are more results; -1 if there are no more results\\n\\\n\\n\\\nNon-standard.\\n\\\n\";\nstatic PyObject *\n_mysql_ConnectionObject_next_result(\n\t_mysql_ConnectionObject *self,\n\tPyObject *args)\n{\n\tint err;\n\tif (!PyArg_ParseTuple(args, \"\")) return NULL;\n\tPy_BEGIN_ALLOW_THREADS\n#if MYSQL_VERSION_ID >= 40100\n\terr = mysql_next_result(&(self->connection));\n#else\n\terr = -1;\n#endif\n\tPy_END_ALLOW_THREADS\n\tif (err > 0) return _mysql_Exception(self);\n\treturn PyInt_FromLong(err);\n}\t\t\n\n#if MYSQL_VERSION_ID >= 40100\n\nstatic char _mysql_ConnectionObject_set_server_option__doc__[] =\n\"set_server_option(option) -- Enables or disables an option\\n\\\nfor the connection.\\n\\\n\\n\\\nNon-standard.\\n\\\n\";\nstatic PyObject *\n_mysql_ConnectionObject_set_server_option(\n\t_mysql_ConnectionObject *self,\n\tPyObject *args)\n{\n\tint err, flags=0;\n\tif (!PyArg_ParseTuple(args, \"i\", &flags))\n\t\treturn NULL;\n\tPy_BEGIN_ALLOW_THREADS\n\terr = mysql_set_server_option(&(self->connection), flags);\n\tPy_END_ALLOW_THREADS\n\tif (err) return _mysql_Exception(self);\n\treturn PyInt_FromLong(err);\n}\t\t\n\nstatic char _mysql_ConnectionObject_sqlstate__doc__[] =\n\"Returns a string containing the SQLSTATE error code\\n\\\nfor the last error. The error code consists of five characters.\\n\\\n'00000' means \\\"no error.\\\" The values are specified by ANSI SQL\\n\\\nand ODBC. For a list of possible values, see section 23\\n\\\nError Handling in MySQL in the MySQL Manual.\\n\\\n\\n\\\nNote that not all MySQL errors are yet mapped to SQLSTATE's.\\n\\\nThe value 'HY000' (general error) is used for unmapped errors.\\n\\\n\\n\\\nNon-standard.\\n\\\n\";\nstatic PyObject *\n_mysql_ConnectionObject_sqlstate(\n\t_mysql_ConnectionObject *self,\n\tPyObject *args)\n{\n\tif (!PyArg_ParseTuple(args, \"\")) return NULL;\n#ifdef IS_PY3K\n\treturn PyUnicode_FromString(mysql_sqlstate(&(self->connection)));\n#else\n\treturn PyString_FromString(mysql_sqlstate(&(self->connection)));\n#endif\n}\n\nstatic char _mysql_ConnectionObject_warning_count__doc__[] =\n\"Returns the number of warnings generated during execution\\n\\\nof the previous SQL statement.\\n\\\n\\n\\\nNon-standard.\\n\\\n\";\nstatic PyObject *\n_mysql_ConnectionObject_warning_count(\n\t_mysql_ConnectionObject *self,\n\tPyObject *args)\n{\n\tif (!PyArg_ParseTuple(args, \"\")) return NULL;\n\treturn PyInt_FromLong(mysql_warning_count(&(self->connection)));\n}\t\t\n\n#endif\n\nstatic char _mysql_ConnectionObject_errno__doc__[] =\n\"Returns the error code for the most recently invoked API function\\n\\\nthat can succeed or fail. A return value of zero means that no error\\n\\\noccurred.\\n\\\n\";\n\nstatic PyObject *\n_mysql_ConnectionObject_errno(\n\t_mysql_ConnectionObject *self,\n\tPyObject *args)\n{\n\tif (!PyArg_ParseTuple(args, \"\")) return NULL;\n\tcheck_connection(self);\n\treturn PyInt_FromLong((long)mysql_errno(&(self->connection)));\n}\n\nstatic char _mysql_ConnectionObject_error__doc__[] =\n\"Returns the error message for the most recently invoked API function\\n\\\nthat can succeed or fail. An empty string (\"\") is returned if no error\\n\\\noccurred.\\n\\\n\";\n\nstatic PyObject *\n_mysql_ConnectionObject_error(\n\t_mysql_ConnectionObject *self,\n\tPyObject *args)\n{\n\tif (!PyArg_ParseTuple(args, \"\")) return NULL;\n\tcheck_connection(self);\n#ifdef IS_PY3K\n\treturn PyUnicode_FromString(mysql_error(&(self->connection)));\n#else\n\treturn PyString_FromString(mysql_error(&(self->connection)));\n#endif\n}\n\nstatic char _mysql_escape_string__doc__[] =\n\"escape_string(s) -- quote any SQL-interpreted characters in string s.\\n\\\n\\n\\\nUse connection.escape_string(s), if you use it at all.\\n\\\n_mysql.escape_string(s) cannot handle character sets. You are\\n\\\nprobably better off using connection.escape(o) instead, since\\n\\\nit will escape entire sequences as well as strings.\";\n\nstatic PyObject *\n_mysql_escape_string(\n\t_mysql_ConnectionObject *self,\n\tPyObject *args)\n{\n\tPyObject *str;\n\tchar *in, *out;\n\tint len, size;\n\tif (!PyArg_ParseTuple(args, \"s#:escape_string\", &in, &size)) return NULL;\n#ifdef IS_PY3K\n\tstr = PyUnicode_FromStringAndSize((char *) NULL, size*2+1);\n#else\n\tstr = PyString_FromStringAndSize((char *) NULL, size*2+1);\n#endif\n\tif (!str) return PyErr_NoMemory();\n#ifdef IS_PY3K\n    out = PyUnicode_AS_DATA(str);\n#else\n    out = PyString_AS_STRING(str);\n#endif\n#if MYSQL_VERSION_ID < 32321\n\tlen = mysql_escape_string(out, in, size);\n#else\n\tcheck_server_init(NULL);\n\tif (self && self->open)\n\t\tlen = mysql_real_escape_string(&(self->connection), out, in, size);\n\telse\n\t\tlen = mysql_escape_string(out, in, size);\n#endif\n#ifdef IS_PY3K\n\tif (PyUnicode_Resize(&str, len) < 0) return NULL;\n#else\n\tif (_PyString_Resize(&str, len) < 0) return NULL;\n#endif\n\treturn (str);\n}\n\nstatic char _mysql_string_literal__doc__[] =\n\"string_literal(obj) -- converts object obj into a SQL string literal.\\n\\\nThis means, any special SQL characters are escaped, and it is enclosed\\n\\\nwithin single quotes. In other words, it performs:\\n\\\n\\n\\\n\\\"'%s'\\\" % escape_string(str(obj))\\n\\\n\\n\\\nUse connection.string_literal(obj), if you use it at all.\\n\\\n_mysql.string_literal(obj) cannot handle character sets.\";\n\nstatic PyObject *\n_mysql_string_literal(\n\t_mysql_ConnectionObject *self,\n\tPyObject *args)\n{\n\tPyObject *str, *s, *o, *d;\n\tchar *in, *out;\n\tint len, size;\n\tif (!PyArg_ParseTuple(args, \"O|O:string_literal\", &o, &d)) return NULL;\n\ts = PyObject_Str(o);\n\tif (!s) return NULL;\n#ifdef IS_PY3K\n\tin = PyUnicode_AS_DATA(s);\n\tsize = PyUnicode_GetSize(s);\n\tstr = PyUnicode_FromStringAndSize((char *) NULL, size*2+3);\n\tif (!str) return PyErr_NoMemory();\n\tout = PyUnicode_AS_DATA(str);\n#else\n\tin = PyString_AsString(s);\n\tsize = PyString_GET_SIZE(s);\n\tstr = PyString_FromStringAndSize((char *) NULL, size*2+3);\n\tif (!str) return PyErr_NoMemory();\n\tout = PyString_AS_STRING(str);\n#endif\n#if MYSQL_VERSION_ID < 32321\n\tlen = mysql_escape_string(out+1, in, size);\n#else\n\tcheck_server_init(NULL);\n\tif (self && self->open)\n\t\tlen = mysql_real_escape_string(&(self->connection), out+1, in, size);\n\telse\n\t\tlen = mysql_escape_string(out+1, in, size);\n#endif\n\t*out = *(out+len+1) = '\\'';\n#ifdef IS_PY3K\n\tif (PyUnicode_Resize(&str, len+2) < 0) return NULL;\n#else\n\tif (_PyString_Resize(&str, len+2) < 0) return NULL;\n#endif\n\tPy_DECREF(s);\n\treturn (str);\n}\n\nstatic PyObject *_mysql_NULL;\n\nstatic PyObject *\n_escape_item(\n\tPyObject *item,\n\tPyObject *d)\n{\n\tPyObject *quoted=NULL, *itemtype, *itemconv;\n\tif (!(itemtype = PyObject_Type(item)))\n\t\tgoto error;\n\titemconv = PyObject_GetItem(d, itemtype);\n\tPy_DECREF(itemtype);\n\tif (!itemconv) {\n\t\tPyErr_Clear();\n\t\titemconv = PyObject_GetItem(d,\n#ifdef IS_PY3K\n\t\t\t\t (PyObject *) &PyUnicode_Type);\n#else\n\t\t\t\t (PyObject *) &PyString_Type);\n#endif\n\t}\n\tif (!itemconv) {\n\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\"no default type converter defined\");\n\t\tgoto error;\n\t}\n\tPy_INCREF(d);\n\tquoted = PyObject_CallFunction(itemconv, \"OO\", item, d);\n\tPy_DECREF(d);\n\tPy_DECREF(itemconv);\nerror:\n\treturn quoted;\n}\n\nstatic char _mysql_escape__doc__[] =\n\"escape(obj, dict) -- escape any special characters in object obj\\n\\\nusing mapping dict to provide quoting functions for each type.\\n\\\nReturns a SQL literal string.\";\nstatic PyObject *\n_mysql_escape(\n\tPyObject *self,\n\tPyObject *args)\n{\n\tPyObject *o=NULL, *d=NULL;\n\tif (!PyArg_ParseTuple(args, \"O|O:escape\", &o, &d))\n\t\treturn NULL;\n\tif (d) {\n\t\tif (!PyMapping_Check(d)) {\n\t\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\t\"argument 2 must be a mapping\");\n\t\t\treturn NULL;\n\t\t}\n\t\treturn _escape_item(o, d);\n\t} else {\n\t\tif (!self) {\n\t\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\t\"argument 2 must be a mapping\");\n\t\t\treturn NULL;\n\t\t}\n\t\treturn _escape_item(o,\n\t\t\t   ((_mysql_ConnectionObject *) self)->converter);\n\t}\n}\n\nstatic char _mysql_escape_sequence__doc__[] =\n\"escape_sequence(seq, dict) -- escape any special characters in sequence\\n\\\nseq using mapping dict to provide quoting functions for each type.\\n\\\nReturns a tuple of escaped items.\";\nstatic PyObject *\n_mysql_escape_sequence(\n\tPyObject *self,\n\tPyObject *args)\n{\n\tPyObject *o=NULL, *d=NULL, *r=NULL, *item, *quoted; \n\tint i, n;\n\tif (!PyArg_ParseTuple(args, \"OO:escape_sequence\", &o, &d))\n\t\tgoto error;\n\tif (!PyMapping_Check(d)) {\n              PyErr_SetString(PyExc_TypeError,\n                              \"argument 2 must be a mapping\");\n              return NULL;\n        }\n\tif ((n = PyObject_Length(o)) == -1) goto error;\n\tif (!(r = PyTuple_New(n))) goto error;\n\tfor (i=0; i<n; i++) {\n\t\titem = PySequence_GetItem(o, i);\n\t\tif (!item) goto error;\n\t\tquoted = _escape_item(item, d);\n\t\tPy_DECREF(item);\n\t\tif (!quoted) goto error;\n\t\tPyTuple_SET_ITEM(r, i, quoted);\n\t}\n\treturn r;\n  error:\n\tPy_XDECREF(r);\n\treturn NULL;\n}\n\nstatic char _mysql_escape_dict__doc__[] =\n\"escape_sequence(d, dict) -- escape any special characters in\\n\\\ndictionary d using mapping dict to provide quoting functions for each type.\\n\\\nReturns a dictionary of escaped items.\";\nstatic PyObject *\n_mysql_escape_dict(\n\tPyObject *self,\n\tPyObject *args)\n{\n\tPyObject *o=NULL, *d=NULL, *r=NULL, *item, *quoted, *pkey; \n\tPy_ssize_t ppos = 0;\n\tif (!PyArg_ParseTuple(args, \"O!O:escape_dict\", &PyDict_Type, &o, &d))\n\t\tgoto error;\n\tif (!PyMapping_Check(d)) {\n              PyErr_SetString(PyExc_TypeError,\n                              \"argument 2 must be a mapping\");\n              return NULL;\n        }\n\tif (!(r = PyDict_New())) goto error;\n\twhile (PyDict_Next(o, &ppos, &pkey, &item)) {\n\t\tquoted = _escape_item(item, d);\n\t\tif (!quoted) goto error;\n\t\tif (PyDict_SetItem(r, pkey, quoted)==-1) goto error;\n\t\tPy_DECREF(quoted);\n\t}\n\treturn r;\n  error:\n\tPy_XDECREF(r);\n\treturn NULL;\n}\n\t\t\t\t\nstatic char _mysql_ResultObject_describe__doc__[] =\n\"Returns the sequence of 7-tuples required by the DB-API for\\n\\\nthe Cursor.description attribute.\\n\\\n\";\n\nstatic PyObject *\n_mysql_ResultObject_describe(\n\t_mysql_ResultObject *self,\n\tPyObject *args)\n{\n\tPyObject *d;\n\tMYSQL_FIELD *fields;\n\tunsigned int i, n;\n\tif (!PyArg_ParseTuple(args, \"\")) return NULL;\n\tcheck_result_connection(self);\n\tn = mysql_num_fields(self->result);\n\tfields = mysql_fetch_fields(self->result);\n\tif (!(d = PyTuple_New(n))) return NULL;\n\tfor (i=0; i<n; i++) {\n\t\tPyObject *t;\n\t\tt = Py_BuildValue(\"(siiiiii)\",\n\t\t\t\t  fields[i].name,\n\t\t\t\t  (long) fields[i].type,\n\t\t\t\t  (long) fields[i].max_length,\n\t\t\t\t  (long) fields[i].length,\n\t\t\t\t  (long) fields[i].length,\n\t\t\t\t  (long) fields[i].decimals,\n\t\t\t\t  (long) !(IS_NOT_NULL(fields[i].flags)));\n\t\tif (!t) goto error;\n\t\tPyTuple_SET_ITEM(d, i, t);\n\t}\n\treturn d;\n  error:\n\tPy_XDECREF(d);\n\treturn NULL;\n}\n\t\nstatic char _mysql_ResultObject_field_flags__doc__[] =\n\"Returns a tuple of field flags, one for each column in the result.\\n\\\n\" ;\n\nstatic PyObject *\n_mysql_ResultObject_field_flags(\n\t_mysql_ResultObject *self,\n\tPyObject *args)\n{\n\tPyObject *d;\n\tMYSQL_FIELD *fields;\n\tunsigned int i, n;\n\tif (!PyArg_ParseTuple(args, \"\")) return NULL;\n\tcheck_result_connection(self);\n\tn = mysql_num_fields(self->result);\n\tfields = mysql_fetch_fields(self->result);\n\tif (!(d = PyTuple_New(n))) return NULL;\n\tfor (i=0; i<n; i++) {\n\t\tPyObject *f;\n\t\tif (!(f = PyInt_FromLong((long)fields[i].flags))) goto error;\n\t\tPyTuple_SET_ITEM(d, i, f);\n\t}\n\treturn d;\n  error:\n\tPy_XDECREF(d);\n\treturn NULL;\n}\n\nstatic PyObject *\n_mysql_field_to_python(\n\tPyObject *converter,\n\tchar *rowitem,\n\tunsigned long length)\n{\n\tPyObject *v;\n\tif (rowitem) {\n\t\tif (converter != Py_None)\n\t\t\tv = PyObject_CallFunction(converter,\n\t\t\t\t\t\t  \"s#\",\n\t\t\t\t\t\t  rowitem,\n\t\t\t\t\t\t  (int)length);\n\t\telse\n#ifdef IS_PY3K\n\t\t\tv = PyUnicode_FromStringAndSize(rowitem,\n\t\t\t\t\t\t       (int)length);\n#else\n\t\t\tv = PyString_FromStringAndSize(rowitem,\n\t\t\t\t\t\t       (int)length);\n#endif\n\t\tif (!v)\n\t\t\treturn NULL;\n\t} else {\n\t\tPy_INCREF(Py_None);\n\t\tv = Py_None;\n\t}\n\treturn v;\n}\n\nstatic PyObject *\n_mysql_row_to_tuple(\n\t_mysql_ResultObject *self,\n\tMYSQL_ROW row)\n{\n\tunsigned int n, i;\n\tunsigned long *length;\n\tPyObject *r, *c;\n\n\tn = mysql_num_fields(self->result);\n\tif (!(r = PyTuple_New(n))) return NULL;\n\tlength = mysql_fetch_lengths(self->result);\n\tfor (i=0; i<n; i++) {\n\t\tPyObject *v;\n\t\tc = PyTuple_GET_ITEM(self->converter, i);\n\t\tv = _mysql_field_to_python(c, row[i], length[i]);\n\t\tif (!v) goto error;\n\t\tPyTuple_SET_ITEM(r, i, v);\n\t}\n\treturn r;\n  error:\n\tPy_XDECREF(r);\n\treturn NULL;\n}\n\nstatic PyObject *\n_mysql_row_to_dict(\n\t_mysql_ResultObject *self,\n\tMYSQL_ROW row)\n{\n\tunsigned int n, i;\n\tunsigned long *length;\n\tPyObject *r, *c;\n        MYSQL_FIELD *fields;\n\n\tn = mysql_num_fields(self->result);\n\tif (!(r = PyDict_New())) return NULL;\n\tlength = mysql_fetch_lengths(self->result);\n        fields = mysql_fetch_fields(self->result);\n\tfor (i=0; i<n; i++) {\n\t\tPyObject *v;\n\t\tc = PyTuple_GET_ITEM(self->converter, i);\n\t\tv = _mysql_field_to_python(c, row[i], length[i]);\n\t\tif (!v) goto error;\n\t\tif (!PyMapping_HasKeyString(r, fields[i].name)) {\n\t\t\tPyMapping_SetItemString(r, fields[i].name, v);\n\t\t} else {\n\t\t\tint len;\n\t\t\tchar buf[256];\n\t\t\tstrncpy(buf, fields[i].table, 256);\n\t\t\tlen = strlen(buf);\n\t\t\tstrncat(buf, \".\", 256-len);\n\t\t\tlen = strlen(buf);\n\t\t\tstrncat(buf, fields[i].name, 256-len);\n\t\t\tPyMapping_SetItemString(r, buf, v);\n\t\t}\n\t\tPy_DECREF(v);\n\t}\n\treturn r;\n  error:\n\tPy_XDECREF(r);\n\treturn NULL;\n}\n\nstatic PyObject *\n_mysql_row_to_dict_old(\n\t_mysql_ResultObject *self,\n\tMYSQL_ROW row)\n{\n\tunsigned int n, i;\n\tunsigned long *length;\n\tPyObject *r, *c;\n        MYSQL_FIELD *fields;\n\n\tn = mysql_num_fields(self->result);\n\tif (!(r = PyDict_New())) return NULL;\n\tlength = mysql_fetch_lengths(self->result);\n        fields = mysql_fetch_fields(self->result);\n\tfor (i=0; i<n; i++) {\n\t\tPyObject *v;\n\t\tc = PyTuple_GET_ITEM(self->converter, i);\n\t\tv = _mysql_field_to_python(c, row[i], length[i]);\n\t\tif (!v) goto error;\n\t\t{\n\t\t\tint len=0;\n\t\t\tchar buf[256]=\"\";\n\t\t\tif (strlen(fields[i].table)) {\n\t\t\t\tstrncpy(buf, fields[i].table, 256);\n\t\t\t\tlen = strlen(buf);\n\t\t\t\tstrncat(buf, \".\", 256-len);\n\t\t\t\tlen = strlen(buf);\n\t\t\t}\n\t\t\tstrncat(buf, fields[i].name, 256-len);\n\t\t\tPyMapping_SetItemString(r, buf, v);\n\t\t}\n\t\tPy_DECREF(v);\n\t}\n\treturn r;\n  error:\n\tPy_XDECREF(r);\n\treturn NULL;\n}\n\ntypedef PyObject *_PYFUNC(_mysql_ResultObject *, MYSQL_ROW);\n\nint\n_mysql__fetch_row(\n\t_mysql_ResultObject *self,\n\tPyObject **r,\n\tint skiprows,\n\tint maxrows,\n\t_PYFUNC *convert_row)\n{\n\tunsigned int i;\n\tMYSQL_ROW row;\n\n\tfor (i = skiprows; i<(skiprows+maxrows); i++) {\n\t\tPyObject *v;\n\t\tif (!self->use)\n\t\t\trow = mysql_fetch_row(self->result);\n\t\telse {\n\t\t\tPy_BEGIN_ALLOW_THREADS;\n\t\t\trow = mysql_fetch_row(self->result);\n\t\t\tPy_END_ALLOW_THREADS;\n\t\t}\n\t\tif (!row && mysql_errno(&(((_mysql_ConnectionObject *)(self->conn))->connection))) {\n\t\t\t_mysql_Exception((_mysql_ConnectionObject *)self->conn);\n\t\t\tgoto error;\n\t\t}\n\t\tif (!row) {\n\t\t\tif (MyTuple_Resize(r, i, 0) == -1) goto error;\n\t\t\tbreak;\n\t\t}\n\t\tv = convert_row(self, row);\n\t\tif (!v) goto error;\n\t\tPyTuple_SET_ITEM(*r, i, v);\n\t}\n\treturn i-skiprows;\n  error:\n\treturn -1;\n}\n\nstatic char _mysql_ResultObject_fetch_row__doc__[] =\n\"fetch_row([maxrows, how]) -- Fetches up to maxrows as a tuple.\\n\\\nThe rows are formatted according to how:\\n\\\n\\n\\\n    0 -- tuples (default)\\n\\\n    1 -- dictionaries, key=column or table.column if duplicated\\n\\\n    2 -- dictionaries, key=table.column\\n\\\n\";\n\nstatic PyObject *\n_mysql_ResultObject_fetch_row(\n\t_mysql_ResultObject *self,\n\tPyObject *args,\n\tPyObject *kwargs)\n{\n\ttypedef PyObject *_PYFUNC(_mysql_ResultObject *, MYSQL_ROW);\n\tstatic char *kwlist[] = { \"maxrows\", \"how\", NULL };\n\tstatic _PYFUNC *row_converters[] =\n\t{\n\t\t_mysql_row_to_tuple,\n\t\t_mysql_row_to_dict,\n\t\t_mysql_row_to_dict_old\n\t};\n\t_PYFUNC *convert_row;\n\tunsigned int maxrows=1, how=0, skiprows=0, rowsadded;\n\tPyObject *r=NULL;\n\n\tif (!PyArg_ParseTupleAndKeywords(args, kwargs, \"|ii:fetch_row\", kwlist,\n\t\t\t\t\t &maxrows, &how))\n\t\treturn NULL;\n\tcheck_result_connection(self);\n\tif (how < 0 || how >= sizeof(row_converters)) {\n\t\tPyErr_SetString(PyExc_ValueError, \"how out of range\");\n\t\treturn NULL;\n\t}\n\tconvert_row = row_converters[how];\n\tif (maxrows) {\n\t\tif (!(r = PyTuple_New(maxrows))) goto error;\n\t\trowsadded = _mysql__fetch_row(self, &r, skiprows, maxrows, \n\t\t\t\tconvert_row);\n\t\tif (rowsadded == -1) goto error;\n\t} else {\n\t\tif (self->use) {\n\t\t\tmaxrows = 1000;\n\t\t\tif (!(r = PyTuple_New(maxrows))) goto error;\n\t\t\twhile (1) {\n\t\t\t\trowsadded = _mysql__fetch_row(self, &r, skiprows,\n\t\t\t\t\t\tmaxrows, convert_row);\n\t\t\t\tif (rowsadded == -1) goto error;\n\t\t\t\tskiprows += rowsadded;\n\t\t\t\tif (rowsadded < maxrows) break;\n\t\t\t\tif (MyTuple_Resize(&r, skiprows+maxrows, 0) == -1)\n\t\t\t\t        goto error;\n\t\t\t}\n\t\t} else {\n\t\t\t/* XXX if overflow, maxrows<0? */\n\t\t\tmaxrows = (int) mysql_num_rows(self->result);\n\t\t\tif (!(r = PyTuple_New(maxrows))) goto error;\n\t\t\trowsadded = _mysql__fetch_row(self, &r, 0,\n\t\t\t\t\tmaxrows, convert_row);\n\t\t\tif (rowsadded == -1) goto error;\n\t\t}\n\t}\n\treturn r;\n  error:\n\tPy_XDECREF(r);\n\treturn NULL;\n}\n\n#if MYSQL_VERSION_ID >= 32303\n\nstatic char _mysql_ConnectionObject_change_user__doc__[] =\n\"Changes the user and causes the database specified by db to\\n\\\nbecome the default (current) database on the connection\\n\\\nspecified by mysql. In subsequent queries, this database is\\n\\\nthe default for table references that do not include an\\n\\\nexplicit database specifier.\\n\\\n\\n\\\nThis function was introduced in MySQL Version 3.23.3.\\n\\\n\\n\\\nFails unless the connected user can be authenticated or if he\\n\\\ndoesn't have permission to use the database. In this case the\\n\\\nuser and database are not changed.\\n\\\n\\n\\\nThe db parameter may be set to None if you don't want to have\\n\\\na default database.\\n\\\n\";\n\nstatic PyObject *\n_mysql_ConnectionObject_change_user(\n\t_mysql_ConnectionObject *self,\n\tPyObject *args,\n\tPyObject *kwargs)\n{\n\tchar *user, *pwd=NULL, *db=NULL;\n\tint r;\n        static char *kwlist[] = { \"user\", \"passwd\", \"db\", NULL } ;\n\n\tif (!PyArg_ParseTupleAndKeywords(args, kwargs, \"s|ss:change_user\",\n\t\t\t\t\t kwlist, &user, &pwd, &db))\n\t\treturn NULL;\n\tcheck_connection(self);\n\tPy_BEGIN_ALLOW_THREADS\n\t\tr = mysql_change_user(&(self->connection), user, pwd, db);\n\tPy_END_ALLOW_THREADS\n\tif (r) \treturn _mysql_Exception(self);\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n#endif\n\nstatic char _mysql_ConnectionObject_character_set_name__doc__[] =\n\"Returns the default character set for the current connection.\\n\\\nNon-standard.\\n\\\n\";\n\nstatic PyObject *\n_mysql_ConnectionObject_character_set_name(\n\t_mysql_ConnectionObject *self,\n\tPyObject *args)\n{\n\tconst char *s;\n\tif (!PyArg_ParseTuple(args, \"\")) return NULL;\n\tcheck_connection(self);\n#if MYSQL_VERSION_ID >= 32321\n\ts = mysql_character_set_name(&(self->connection));\n#else\n\ts = \"latin1\";\n#endif\n#ifdef IS_PY3K\n\treturn PyUnicode_FromString(s);\n#else\n\treturn PyString_FromString(s);\n#endif\n}\n\n#if MYSQL_VERSION_ID >= 50007\nstatic char _mysql_ConnectionObject_set_character_set__doc__[] =\n\"Sets the default character set for the current connection.\\n\\\nNon-standard.\\n\\\n\";\n\nstatic PyObject *\n_mysql_ConnectionObject_set_character_set(\n\t_mysql_ConnectionObject *self,\n\tPyObject *args)\n{\n\tconst char *s;\n\tint err;\n\tif (!PyArg_ParseTuple(args, \"s\", &s)) return NULL;\n\tcheck_connection(self);\n\tPy_BEGIN_ALLOW_THREADS\n\terr = mysql_set_character_set(&(self->connection), s);\n\tPy_END_ALLOW_THREADS\n\tif (err) return _mysql_Exception(self);\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n#endif\n\n#if MYSQL_VERSION_ID >= 50010\nstatic char _mysql_ConnectionObject_get_character_set_info__doc__[] =\n\"Returns a dict with information about the current character set:\\n\\\n\\n\\\ncollation\\n\\\n    collation name\\n\\\nname\\n\\\n    character set name\\n\\\ncomment\\n\\\n    comment or descriptive name\\n\\\ndir\\n\\\n    character set directory\\n\\\nmbminlen\\n\\\n    min. length for multibyte string\\n\\\nmbmaxlen\\n\\\n    max. length for multibyte string\\n\\\n\\n\\\nNot all keys may be present, particularly dir.\\n\\\n\\n\\\nNon-standard.\\n\\\n\";\n\nstatic PyObject *\n_mysql_ConnectionObject_get_character_set_info(\n\t_mysql_ConnectionObject *self,\n\tPyObject *args)\n{\n\tPyObject *result;\n\tMY_CHARSET_INFO cs;\n\t\n\tif (!PyArg_ParseTuple(args, \"\")) return NULL;\n\tcheck_connection(self);\n\tmysql_get_character_set_info(&(self->connection), &cs);\n\tif (!(result = PyDict_New())) return NULL;\n#ifdef IS_PY3K\n\tif (cs.csname)\n\t\tPyDict_SetItemString(result, \"name\", PyUnicode_FromString(cs.csname));\n\tif (cs.name)\n\t\tPyDict_SetItemString(result, \"collation\", PyUnicode_FromString(cs.name));\n\tif (cs.comment)\n\t\tPyDict_SetItemString(result, \"comment\", PyUnicode_FromString(cs.comment));\n\tif (cs.dir)\n\t\tPyDict_SetItemString(result, \"dir\", PyUnicode_FromString(cs.dir));\n\tPyDict_SetItemString(result, \"mbminlen\", PyInt_FromLong(cs.mbminlen));\n\tPyDict_SetItemString(result, \"mbmaxlen\", PyInt_FromLong(cs.mbmaxlen));\n#else\n\tif (cs.csname)\n\t\tPyDict_SetItemString(result, \"name\", PyString_FromString(cs.csname));\n\tif (cs.name)\n\t\tPyDict_SetItemString(result, \"collation\", PyString_FromString(cs.name));\n\tif (cs.comment)\n\t\tPyDict_SetItemString(result, \"comment\", PyString_FromString(cs.comment));\n\tif (cs.dir)\n\t\tPyDict_SetItemString(result, \"dir\", PyString_FromString(cs.dir));\n\tPyDict_SetItemString(result, \"mbminlen\", PyInt_FromLong(cs.mbminlen));\n\tPyDict_SetItemString(result, \"mbmaxlen\", PyInt_FromLong(cs.mbmaxlen));\n#endif\n\treturn result;\n}\n#endif\n\nstatic char _mysql_get_client_info__doc__[] =\n\"get_client_info() -- Returns a string that represents\\n\\\nthe client library version.\";\nstatic PyObject *\n_mysql_get_client_info(\n\tPyObject *self,\n\tPyObject *args)\n{\n\tif (!PyArg_ParseTuple(args, \"\")) return NULL;\n\tcheck_server_init(NULL);\n#ifdef IS_PY3K\n\treturn PyUnicode_FromString(mysql_get_client_info());\n#else\n\treturn PyString_FromString(mysql_get_client_info());\n#endif\n}\n\nstatic char _mysql_ConnectionObject_get_host_info__doc__[] =\n\"Returns a string that represents the MySQL client library\\n\\\nversion. Non-standard.\\n\\\n\";\n\nstatic PyObject *\n_mysql_ConnectionObject_get_host_info(\n\t_mysql_ConnectionObject *self,\n\tPyObject *args)\n{\n\tif (!PyArg_ParseTuple(args, \"\")) return NULL;\n\tcheck_connection(self);\n#ifdef IS_PY3K\n\treturn PyUnicode_FromString(mysql_get_host_info(&(self->connection)));\n#else\n\treturn PyString_FromString(mysql_get_host_info(&(self->connection)));\n#endif\n}\n\nstatic char _mysql_ConnectionObject_get_proto_info__doc__[] =\n\"Returns an unsigned integer representing the protocol version\\n\\\nused by the current connection. Non-standard.\\n\\\n\";\n\nstatic PyObject *\n_mysql_ConnectionObject_get_proto_info(\n\t_mysql_ConnectionObject *self,\n\tPyObject *args)\n{\n\tif (!PyArg_ParseTuple(args, \"\")) return NULL;\n\tcheck_connection(self);\n\treturn PyInt_FromLong((long)mysql_get_proto_info(&(self->connection)));\n}\n\nstatic char _mysql_ConnectionObject_get_server_info__doc__[] =\n\"Returns a string that represents the server version number.\\n\\\nNon-standard.\\n\\\n\";\n\nstatic PyObject *\n_mysql_ConnectionObject_get_server_info(\n\t_mysql_ConnectionObject *self,\n\tPyObject *args)\n{\n\tif (!PyArg_ParseTuple(args, \"\")) return NULL;\n\tcheck_connection(self);\n#ifdef IS_PY3K\n\treturn PyUnicode_FromString(mysql_get_server_info(&(self->connection)));\n#else\n\treturn PyString_FromString(mysql_get_server_info(&(self->connection)));\n#endif\n}\n\nstatic char _mysql_ConnectionObject_info__doc__[] =\n\"Retrieves a string providing information about the most\\n\\\nrecently executed query. Non-standard. Use messages or\\n\\\nCursor.messages.\\n\\\n\";\n\nstatic PyObject *\n_mysql_ConnectionObject_info(\n\t_mysql_ConnectionObject *self,\n\tPyObject *args)\n{\n\tconst char *s;\n\tif (!PyArg_ParseTuple(args, \"\")) return NULL;\n\tcheck_connection(self);\n\ts = mysql_info(&(self->connection));\n#ifdef IS_PY3K\n\tif (s) return PyUnicode_FromString(s);\n#else\n\tif (s) return PyString_FromString(s);\n#endif\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic char _mysql_ConnectionObject_insert_id__doc__[] =\n\"Returns the ID generated for an AUTO_INCREMENT column by the previous\\n\\\nquery. Use this function after you have performed an INSERT query into a\\n\\\ntable that contains an AUTO_INCREMENT field.\\n\\\n\\n\\\nNote that this returns 0 if the previous query does not\\n\\\ngenerate an AUTO_INCREMENT value. If you need to save the value for\\n\\\nlater, be sure to call this immediately after the query\\n\\\nthat generates the value.\\n\\\n\\n\\\nThe ID is updated after INSERT and UPDATE statements that generate\\n\\\nan AUTO_INCREMENT value or that set a column value to\\n\\\nLAST_INSERT_ID(expr). See section 6.3.5.2 Miscellaneous Functions\\n\\\nin the MySQL documentation.\\n\\\n\\n\\\nAlso note that the value of the SQL LAST_INSERT_ID() function always\\n\\\ncontains the most recently generated AUTO_INCREMENT value, and is not\\n\\\nreset between queries because the value of that function is maintained\\n\\\nin the server.\\n\\\n\" ;\n\nstatic PyObject *\n_mysql_ConnectionObject_insert_id(\n\t_mysql_ConnectionObject *self,\n\tPyObject *args)\n{\n\tmy_ulonglong r;\n\tif (!PyArg_ParseTuple(args, \"\")) return NULL;\n\tcheck_connection(self);\n\tPy_BEGIN_ALLOW_THREADS\n\tr = mysql_insert_id(&(self->connection));\n\tPy_END_ALLOW_THREADS\n\treturn PyLong_FromUnsignedLongLong(r);\n}\n\nstatic char _mysql_ConnectionObject_kill__doc__[] =\n\"Asks the server to kill the thread specified by pid.\\n\\\nNon-standard.\";\n\nstatic PyObject *\n_mysql_ConnectionObject_kill(\n\t_mysql_ConnectionObject *self,\n\tPyObject *args)\n{\n\tunsigned long pid;\n\tint r;\n\tif (!PyArg_ParseTuple(args, \"k:kill\", &pid)) return NULL;\n\tcheck_connection(self);\n\tPy_BEGIN_ALLOW_THREADS\n\tr = mysql_kill(&(self->connection), pid);\n\tPy_END_ALLOW_THREADS\n\tif (r) return _mysql_Exception(self);\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic char _mysql_ConnectionObject_field_count__doc__[] =\n\"Returns the number of columns for the most recent query on the\\n\\\nconnection. Non-standard. Will probably give you bogus results\\n\\\non most cursor classes. Use Cursor.rowcount.\\n\\\n\";\n\nstatic PyObject *\n_mysql_ConnectionObject_field_count(\n\t_mysql_ConnectionObject *self,\n\tPyObject *args)\n{\n\tif (!PyArg_ParseTuple(args, \"\")) return NULL;\n\tcheck_connection(self);\n#if MYSQL_VERSION_ID < 32224\n\treturn PyInt_FromLong((long)mysql_num_fields(&(self->connection)));\n#else\n\treturn PyInt_FromLong((long)mysql_field_count(&(self->connection)));\n#endif\n}\t\n\nstatic char _mysql_ResultObject_num_fields__doc__[] =\n\"Returns the number of fields (column) in the result.\" ;\n\nstatic PyObject *\n_mysql_ResultObject_num_fields(\n\t_mysql_ResultObject *self,\n\tPyObject *args)\n{\n\tif (!PyArg_ParseTuple(args, \"\")) return NULL;\n\tcheck_result_connection(self);\n\treturn PyInt_FromLong((long)mysql_num_fields(self->result));\n}\t\n\nstatic char _mysql_ResultObject_num_rows__doc__[] =\n\"Returns the number of rows in the result set. Note that if\\n\\\nuse=1, this will not return a valid value until the entire result\\n\\\nset has been read.\\n\\\n\";\n\nstatic PyObject *\n_mysql_ResultObject_num_rows(\n\t_mysql_ResultObject *self,\n\tPyObject *args)\n{\n\tif (!PyArg_ParseTuple(args, \"\")) return NULL;\n\tcheck_result_connection(self);\n\treturn PyLong_FromUnsignedLongLong(mysql_num_rows(self->result));\n}\t\n\nstatic char _mysql_ConnectionObject_ping__doc__[] =\n\"Checks whether or not the connection to the server is\\n\\\nworking. If it has gone down, an automatic reconnection is\\n\\\nattempted.\\n\\\n\\n\\\nThis function can be used by clients that remain idle for a\\n\\\nlong while, to check whether or not the server has closed the\\n\\\nconnection and reconnect if necessary.\\n\\\n\\n\\\nNew in 1.2.2: Accepts an optional reconnect parameter. If True,\\n\\\nthen the client will attempt reconnection. Note that this setting\\n\\\nis persistent. By default, this is on in MySQL<5.0.3, and off\\n\\\nthereafter.\\n\\\n\\n\\\nNon-standard. You should assume that ping() performs an\\n\\\nimplicit rollback; use only when starting a new transaction.\\n\\\nYou have been warned.\\n\\\n\";\n\nstatic PyObject *\n_mysql_ConnectionObject_ping(\n\t_mysql_ConnectionObject *self,\n\tPyObject *args)\n{\n\tint r, reconnect = -1;\n\tif (!PyArg_ParseTuple(args, \"|I\", &reconnect)) return NULL;\n\tcheck_connection(self);\n\tif ( reconnect != -1 ) self->connection.reconnect = reconnect;\n\tPy_BEGIN_ALLOW_THREADS\n\tr = mysql_ping(&(self->connection));\n\tPy_END_ALLOW_THREADS\n\tif (r) \treturn _mysql_Exception(self);\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic char _mysql_ConnectionObject_query__doc__[] =\n\"Execute a query. store_result() or use_result() will get the\\n\\\nresult set, if any. Non-standard. Use cursor() to create a cursor,\\n\\\nthen cursor.execute().\\n\\\n\" ;\n\nstatic PyObject *\n_mysql_ConnectionObject_query(\n\t_mysql_ConnectionObject *self,\n\tPyObject *args)\n{\n\tchar *query;\n\tint len, r;\n\tif (!PyArg_ParseTuple(args, \"s#:query\", &query, &len)) return NULL;\n\tcheck_connection(self);\n\tPy_BEGIN_ALLOW_THREADS\n\tr = mysql_real_query(&(self->connection), query, len);\n\tPy_END_ALLOW_THREADS\n\tif (r) return _mysql_Exception(self);\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\n\nstatic char _mysql_ConnectionObject_select_db__doc__[] =\n\"Causes the database specified by db to become the default\\n\\\n(current) database on the connection specified by mysql. In subsequent\\n\\\nqueries, this database is the default for table references that do not\\n\\\ninclude an explicit database specifier.\\n\\\n\\n\\\nFails unless the connected user can be authenticated as having\\n\\\npermission to use the database.\\n\\\n\\n\\\nNon-standard.\\n\\\n\";\n\nstatic PyObject *\n_mysql_ConnectionObject_select_db(\n\t_mysql_ConnectionObject *self,\n\tPyObject *args)\n{\n\tchar *db;\n\tint r;\n\tif (!PyArg_ParseTuple(args, \"s:select_db\", &db)) return NULL;\n\tcheck_connection(self);\n\tPy_BEGIN_ALLOW_THREADS\n\tr = mysql_select_db(&(self->connection), db);\n\tPy_END_ALLOW_THREADS\n\tif (r) \treturn _mysql_Exception(self);\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic char _mysql_ConnectionObject_shutdown__doc__[] =\n\"Asks the database server to shut down. The connected user must\\n\\\nhave shutdown privileges. Non-standard.\\n\\\n\";\n\nstatic PyObject *\n_mysql_ConnectionObject_shutdown(\n\t_mysql_ConnectionObject *self,\n\tPyObject *args)\n{\n\tint r;\n\tif (!PyArg_ParseTuple(args, \"\")) return NULL;\n\tcheck_connection(self);\n\tPy_BEGIN_ALLOW_THREADS\n\tr = mysql_shutdown(&(self->connection)\n#if MYSQL_VERSION_ID >= 40103\n\t\t, SHUTDOWN_DEFAULT\n#endif\n\t\t);\n\tPy_END_ALLOW_THREADS\n\tif (r) return _mysql_Exception(self);\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic char _mysql_ConnectionObject_stat__doc__[] =\n\"Returns a character string containing information similar to\\n\\\nthat provided by the mysqladmin status command. This includes\\n\\\nuptime in seconds and the number of running threads,\\n\\\nquestions, reloads, and open tables. Non-standard.\\n\\\n\";\n\nstatic PyObject *\n_mysql_ConnectionObject_stat(\n\t_mysql_ConnectionObject *self,\n\tPyObject *args)\n{\n\tconst char *s;\n\tif (!PyArg_ParseTuple(args, \"\")) return NULL;\n\tcheck_connection(self);\n\tPy_BEGIN_ALLOW_THREADS\n\ts = mysql_stat(&(self->connection));\n\tPy_END_ALLOW_THREADS\n\tif (!s) return _mysql_Exception(self);\n#ifdef IS_PY3K\n\treturn PyUnicode_FromString(s);\n#else\n\treturn PyString_FromString(s);\n#endif\n\n}\n\nstatic char _mysql_ConnectionObject_store_result__doc__[] =\n\"Returns a result object acquired by mysql_store_result\\n\\\n(results stored in the client). If no results are available,\\n\\\nNone is returned. Non-standard.\\n\\\n\";\n\nstatic PyObject *\n_mysql_ConnectionObject_store_result(\n\t_mysql_ConnectionObject *self,\n\tPyObject *args)\n{\n\tPyObject *arglist=NULL, *kwarglist=NULL, *result=NULL;\n\t_mysql_ResultObject *r=NULL;\n\n\tif (!PyArg_ParseTuple(args, \"\")) return NULL;\n\tcheck_connection(self);\n\targlist = Py_BuildValue(\"(OiO)\", self, 0, self->converter);\n\tif (!arglist) goto error;\n\tkwarglist = PyDict_New();\n\tif (!kwarglist) goto error;\n\tr = MyAlloc(_mysql_ResultObject, _mysql_ResultObject_Type);\n\tif (!r) goto error;\n\tif (_mysql_ResultObject_Initialize(r, arglist, kwarglist))\n\t\tgoto error;\n\tresult = (PyObject *) r;\n\tif (!(r->result)) {\n\t\tPy_DECREF(result);\n\t\tPy_INCREF(Py_None);\n\t\tresult = Py_None;\n\t}\n  error:\n\tPy_XDECREF(arglist);\n\tPy_XDECREF(kwarglist);\n\treturn result;\n}\n\nstatic char _mysql_ConnectionObject_thread_id__doc__[] =\n\"Returns the thread ID of the current connection. This value\\n\\\ncan be used as an argument to kill() to kill the thread.\\n\\\n\\n\\\nIf the connection is lost and you reconnect with ping(), the\\n\\\nthread ID will change. This means you should not get the\\n\\\nthread ID and store it for later. You should get it when you\\n\\\nneed it.\\n\\\n\\n\\\nNon-standard.\";\n\nstatic PyObject *\n_mysql_ConnectionObject_thread_id(\n\t_mysql_ConnectionObject *self,\n\tPyObject *args)\n{\n\tunsigned long pid;\n\tif (!PyArg_ParseTuple(args, \"\")) return NULL;\n\tcheck_connection(self);\n\tPy_BEGIN_ALLOW_THREADS\n\tpid = mysql_thread_id(&(self->connection));\n\tPy_END_ALLOW_THREADS\n\treturn PyInt_FromLong((long)pid);\n}\n\nstatic char _mysql_ConnectionObject_use_result__doc__[] =\n\"Returns a result object acquired by mysql_use_result\\n\\\n(results stored in the server). If no results are available,\\n\\\nNone is returned. Non-standard.\\n\\\n\";\n\nstatic PyObject *\n_mysql_ConnectionObject_use_result(\n\t_mysql_ConnectionObject *self,\n\tPyObject *args)\n{\n\tPyObject *arglist=NULL, *kwarglist=NULL, *result=NULL;\n\t_mysql_ResultObject *r=NULL;\n\n\tif (!PyArg_ParseTuple(args, \"\")) return NULL;\n\tcheck_connection(self);\n\targlist = Py_BuildValue(\"(OiO)\", self, 1, self->converter);\n\tif (!arglist) return NULL;\n\tkwarglist = PyDict_New();\n\tif (!kwarglist) goto error;\n\tr = MyAlloc(_mysql_ResultObject, _mysql_ResultObject_Type);\n\tif (!r) goto error;\n\tresult = (PyObject *) r;\n\tif (_mysql_ResultObject_Initialize(r, arglist, kwarglist))\n\t\tgoto error;\n\tif (!(r->result)) {\n\t\tPy_DECREF(result);\n\t\tPy_INCREF(Py_None);\n\t\tresult = Py_None;\n\t}\n  error:\n\tPy_DECREF(arglist);\n\tPy_XDECREF(kwarglist);\n\treturn result;\n}\n\nstatic void\n_mysql_ConnectionObject_dealloc(\n\t_mysql_ConnectionObject *self)\n{\n\tPyObject *o;\n\n\tPyObject_GC_UnTrack(self);\n\tif (self->open) {\n\t\to = _mysql_ConnectionObject_close(self, NULL);\n\t\tPy_XDECREF(o);\n\t}\n\tMyFree(self);\n}\n\nstatic PyObject *\n_mysql_ConnectionObject_repr(\n\t_mysql_ConnectionObject *self)\n{\n\tchar buf[300];\n\tif (self->open)\n\t\tsprintf(buf, \"<_mysql.connection open to '%.256s' at %lx>\",\n\t\t\tself->connection.host,\n\t\t\t(long)self);\n\telse\n\t\tsprintf(buf, \"<_mysql.connection closed at %lx>\",\n\t\t\t(long)self);\n#ifdef IS_PY3K\n\treturn PyUnicode_FromString(buf);\n#else\n\treturn PyString_FromString(buf);\n#endif\n}\n\nstatic char _mysql_ResultObject_data_seek__doc__[] =\n\"data_seek(n) -- seek to row n of result set\";\nstatic PyObject *\n_mysql_ResultObject_data_seek(\n     _mysql_ResultObject *self,\n     PyObject *args)\n{\n\tunsigned int row;\n\tif (!PyArg_ParseTuple(args, \"i:data_seek\", &row)) return NULL;\n\tcheck_result_connection(self);\n\tmysql_data_seek(self->result, row);\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic char _mysql_ResultObject_row_seek__doc__[] =\n\"row_seek(n) -- seek by offset n rows of result set\";\nstatic PyObject *\n_mysql_ResultObject_row_seek(\n     _mysql_ResultObject *self,\n     PyObject *args)\n{\n\tint offset;\n        MYSQL_ROW_OFFSET r;\n\tif (!PyArg_ParseTuple(args, \"i:row_seek\", &offset)) return NULL;\n\tcheck_result_connection(self);\n\tif (self->use) {\n\t\tPyErr_SetString(_mysql_ProgrammingError,\n\t\t\t\t\"cannot be used with connection.use_result()\");\n\t\treturn NULL;\n\t}\n\tr = mysql_row_tell(self->result);\n\tmysql_row_seek(self->result, r+offset);\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic char _mysql_ResultObject_row_tell__doc__[] =\n\"row_tell() -- return the current row number of the result set.\";\nstatic PyObject *\n_mysql_ResultObject_row_tell(\n\t_mysql_ResultObject *self,\n\tPyObject *args)\n{\n\tMYSQL_ROW_OFFSET r;\n\tif (!PyArg_ParseTuple(args, \"\")) return NULL;\n\tcheck_result_connection(self);\n\tif (self->use) {\n\t\tPyErr_SetString(_mysql_ProgrammingError,\n\t\t\t\t\"cannot be used with connection.use_result()\");\n\t\treturn NULL;\n\t}\n\tr = mysql_row_tell(self->result);\n\treturn PyInt_FromLong(r-self->result->data->data);\n}\n\nstatic void\n_mysql_ResultObject_dealloc(\n\t_mysql_ResultObject *self)\n{\n\tPyObject_GC_UnTrack((PyObject *)self);\n\tmysql_free_result(self->result);\n\t_mysql_ResultObject_clear(self);\n\tMyFree(self);\n}\n\nstatic PyObject *\n_mysql_ResultObject_repr(\n\t_mysql_ResultObject *self)\n{\n\tchar buf[300];\n\tsprintf(buf, \"<_mysql.result object at %lx>\",\n\t\t(long)self);\n#ifdef IS_PY3K\n\treturn PyUnicode_FromString(buf);\n#else\n\treturn PyString_FromString(buf);\n#endif\n}\n\nstatic PyMethodDef _mysql_ConnectionObject_methods[] = {\n\t{\n\t\t\"affected_rows\",\n\t\t(PyCFunction)_mysql_ConnectionObject_affected_rows,\n\t\tMETH_VARARGS,\n\t\t_mysql_ConnectionObject_affected_rows__doc__\n\t},\n\t{\n\t\t\"autocommit\",\n\t\t(PyCFunction)_mysql_ConnectionObject_autocommit,\n\t\tMETH_VARARGS,\n\t\t_mysql_ConnectionObject_autocommit__doc__\n\t},\n\t{\n\t\t\"get_autocommit\",\n\t\t(PyCFunction)_mysql_ConnectionObject_get_autocommit,\n\t\tMETH_NOARGS,\n\t\t_mysql_ConnectionObject_get_autocommit__doc__\n\t},\n\t{\n\t\t\"commit\",\n\t\t(PyCFunction)_mysql_ConnectionObject_commit,\n\t\tMETH_VARARGS,\n\t\t_mysql_ConnectionObject_commit__doc__\n\t},\n\t{\n\t\t\"rollback\",\n\t\t(PyCFunction)_mysql_ConnectionObject_rollback,\n\t\tMETH_VARARGS,\n\t\t_mysql_ConnectionObject_rollback__doc__\n\t},\n\t{\n\t\t\"next_result\",\n\t\t(PyCFunction)_mysql_ConnectionObject_next_result,\n\t\tMETH_VARARGS,\n\t\t_mysql_ConnectionObject_next_result__doc__\n\t},\n#if MYSQL_VERSION_ID >= 40100\n\t{\n\t\t\"set_server_option\",\n\t\t(PyCFunction)_mysql_ConnectionObject_set_server_option,\n\t\tMETH_VARARGS,\n\t\t_mysql_ConnectionObject_set_server_option__doc__\n\t},\n\t{\n\t\t\"sqlstate\",\n\t\t(PyCFunction)_mysql_ConnectionObject_sqlstate,\n\t\tMETH_VARARGS,\n\t\t_mysql_ConnectionObject_sqlstate__doc__\n\t},\n\t{\n\t\t\"warning_count\",\n\t\t(PyCFunction)_mysql_ConnectionObject_warning_count,\n\t\tMETH_VARARGS,\n\t\t_mysql_ConnectionObject_warning_count__doc__\n\t},\n#endif\n#if MYSQL_VERSION_ID >= 32303\n\t{\n\t\t\"change_user\",\n\t\t(PyCFunction)_mysql_ConnectionObject_change_user,\n\t\tMETH_VARARGS | METH_KEYWORDS,\n\t\t_mysql_ConnectionObject_change_user__doc__\n\t},\n#endif\n\t{\n\t\t\"character_set_name\",\n\t\t(PyCFunction)_mysql_ConnectionObject_character_set_name,\n\t\tMETH_VARARGS,\n\t\t_mysql_ConnectionObject_character_set_name__doc__\n\t},\n#if MYSQL_VERSION_ID >= 50007\n\t{\n\t\t\"set_character_set\",\n\t\t(PyCFunction)_mysql_ConnectionObject_set_character_set,\n\t\tMETH_VARARGS,\n\t\t_mysql_ConnectionObject_set_character_set__doc__\n\t},\n#endif\n#if MYSQL_VERSION_ID >= 50010\n\t{\n\t\t\"get_character_set_info\",\n\t\t(PyCFunction)_mysql_ConnectionObject_get_character_set_info,\n\t\tMETH_VARARGS,\n\t\t_mysql_ConnectionObject_get_character_set_info__doc__\n\t},\n#endif\n\t{\n\t\t\"close\",\n\t\t(PyCFunction)_mysql_ConnectionObject_close,\n\t\tMETH_VARARGS,\n\t\t_mysql_ConnectionObject_close__doc__\n\t},\n\t{\n\t\t\"dump_debug_info\",\n\t\t(PyCFunction)_mysql_ConnectionObject_dump_debug_info,\n\t\tMETH_VARARGS,\n\t\t_mysql_ConnectionObject_dump_debug_info__doc__\n\t},\n\t{\n\t\t\"escape\",\n\t\t(PyCFunction)_mysql_escape,\n\t\tMETH_VARARGS,\n\t\t_mysql_escape__doc__\n\t},\n\t{\n\t\t\"escape_string\",\n\t\t(PyCFunction)_mysql_escape_string,\n\t\tMETH_VARARGS,\n\t\t_mysql_escape_string__doc__\n\t},\n\t{\n\t\t\"error\",\n\t\t(PyCFunction)_mysql_ConnectionObject_error,\n\t\tMETH_VARARGS,\n\t\t_mysql_ConnectionObject_error__doc__\n\t},\n\t{\n\t\t\"errno\",\n\t\t(PyCFunction)_mysql_ConnectionObject_errno,\n\t\tMETH_VARARGS,\n\t\t_mysql_ConnectionObject_errno__doc__\n\t},\n\t{\n\t\t\"field_count\",\n\t\t(PyCFunction)_mysql_ConnectionObject_field_count,\n\t\tMETH_VARARGS,\n\t\t_mysql_ConnectionObject_field_count__doc__\n\t}, \n\t{\n\t\t\"get_host_info\",\n\t\t(PyCFunction)_mysql_ConnectionObject_get_host_info,\n\t\tMETH_VARARGS,\n\t\t_mysql_ConnectionObject_get_host_info__doc__\n\t},\n\t{\n\t\t\"get_proto_info\",\n\t\t(PyCFunction)_mysql_ConnectionObject_get_proto_info,\n\t\tMETH_VARARGS,\n\t\t_mysql_ConnectionObject_get_proto_info__doc__\n\t},\n\t{\n\t\t\"get_server_info\",\n\t\t(PyCFunction)_mysql_ConnectionObject_get_server_info,\n\t\tMETH_VARARGS,\n\t\t_mysql_ConnectionObject_get_server_info__doc__\n\t},\n\t{\n\t\t\"info\",\n\t\t(PyCFunction)_mysql_ConnectionObject_info,\n\t\tMETH_VARARGS,\n\t\t_mysql_ConnectionObject_info__doc__\n\t},\n\t{\n\t\t\"insert_id\",\n\t\t(PyCFunction)_mysql_ConnectionObject_insert_id,\n\t\tMETH_VARARGS,\n\t\t_mysql_ConnectionObject_insert_id__doc__\n\t},\n\t{\n\t\t\"kill\",\n\t\t(PyCFunction)_mysql_ConnectionObject_kill,\n\t\tMETH_VARARGS,\n\t\t_mysql_ConnectionObject_kill__doc__\n\t},\n\t{\n\t\t\"ping\",\n\t\t(PyCFunction)_mysql_ConnectionObject_ping,\n\t\tMETH_VARARGS,\n\t\t_mysql_ConnectionObject_ping__doc__\n\t},\n\t{\n\t\t\"query\",\n\t\t(PyCFunction)_mysql_ConnectionObject_query,\n\t\tMETH_VARARGS,\n\t\t_mysql_ConnectionObject_query__doc__\n\t},\n\t{\n\t\t\"select_db\",\n\t\t(PyCFunction)_mysql_ConnectionObject_select_db,\n\t\tMETH_VARARGS,\n\t\t_mysql_ConnectionObject_select_db__doc__\n\t},\n\t{\n\t\t\"shutdown\",\n\t\t(PyCFunction)_mysql_ConnectionObject_shutdown,\n\t\tMETH_VARARGS,\n\t\t_mysql_ConnectionObject_shutdown__doc__\n\t},\n\t{\n\t\t\"stat\",\n\t\t(PyCFunction)_mysql_ConnectionObject_stat,\n\t\tMETH_VARARGS,\n\t\t_mysql_ConnectionObject_stat__doc__\n\t},\n\t{\n\t\t\"store_result\",\n\t\t(PyCFunction)_mysql_ConnectionObject_store_result,\n\t\tMETH_VARARGS,\n\t\t_mysql_ConnectionObject_store_result__doc__\n\t},\n\t{\n\t\t\"string_literal\",\n\t\t(PyCFunction)_mysql_string_literal,\n\t\tMETH_VARARGS,\n\t\t_mysql_string_literal__doc__},\n\t{\n\t\t\"thread_id\",\n\t\t(PyCFunction)_mysql_ConnectionObject_thread_id,\n\t\tMETH_VARARGS,\n\t\t_mysql_ConnectionObject_thread_id__doc__\n\t},\n\t{\n\t\t\"use_result\",\n\t\t(PyCFunction)_mysql_ConnectionObject_use_result,\n\t\tMETH_VARARGS,\n\t\t_mysql_ConnectionObject_use_result__doc__\n\t},\n\t{NULL,              NULL} /* sentinel */\n};\n\nstatic MyMemberlist(_mysql_ConnectionObject_memberlist)[] = {\n\tMyMember(\n\t\t\"open\",\n\t\tT_INT,\n\t\toffsetof(_mysql_ConnectionObject,open),\n\t\tREADONLY,\n\t\t\"True if connection is open\"\n\t\t),\n\tMyMember(\n\t\t\"converter\",\n\t\tT_OBJECT,\n\t\toffsetof(_mysql_ConnectionObject,converter),\n\t\t0,\n\t\t\"Type conversion mapping\"\n\t\t),\n\tMyMember(\n\t\t\"server_capabilities\",\n\t\tT_UINT,\n\t\toffsetof(_mysql_ConnectionObject,connection.server_capabilities),\n\t\tREADONLY,\n\t\t\"Capabilites of server; consult MySQLdb.constants.CLIENT\"\n\t\t),\n\tMyMember(\n\t\t \"port\",\n\t\t T_UINT,\n\t\t offsetof(_mysql_ConnectionObject,connection.port),\n\t\t READONLY,\n\t\t \"TCP/IP port of the server connection\"\n\t\t ),\n\tMyMember(\n\t\t \"client_flag\",\n\t\t T_UINT,\n\t\t READONLY,\n\t\t offsetof(_mysql_ConnectionObject,connection.client_flag),\n\t\t \"Client flags; refer to MySQLdb.constants.CLIENT\"\n\t\t ),\n\t{NULL} /* Sentinel */\n};\n\nstatic PyMethodDef _mysql_ResultObject_methods[] = {\n\t{\n\t\t\"data_seek\",\n\t\t(PyCFunction)_mysql_ResultObject_data_seek,\n\t\tMETH_VARARGS,\n\t\t_mysql_ResultObject_data_seek__doc__\n\t},\n\t{\n\t\t\"row_seek\",\n\t\t(PyCFunction)_mysql_ResultObject_row_seek,\n\t\tMETH_VARARGS,\n\t\t_mysql_ResultObject_row_seek__doc__\n\t},\n\t{\n\t\t\"row_tell\",\n\t\t(PyCFunction)_mysql_ResultObject_row_tell,\n\t\tMETH_VARARGS,\n\t\t_mysql_ResultObject_row_tell__doc__\n\t},\n\t{\n\t\t\"describe\",\n\t\t(PyCFunction)_mysql_ResultObject_describe,\n\t\tMETH_VARARGS,\n\t\t_mysql_ResultObject_describe__doc__\n\t},\n\t{\n\t\t\"fetch_row\",\n\t\t(PyCFunction)_mysql_ResultObject_fetch_row,\n\t\tMETH_VARARGS | METH_KEYWORDS,\n\t\t_mysql_ResultObject_fetch_row__doc__\n\t},\n\t{\n\t\t\"field_flags\",\n\t\t(PyCFunction)_mysql_ResultObject_field_flags,\n\t\tMETH_VARARGS,\n\t\t_mysql_ResultObject_field_flags__doc__\n\t},\n\t{\n\t\t\"num_fields\",\n\t\t(PyCFunction)_mysql_ResultObject_num_fields,\n\t\tMETH_VARARGS,\n\t\t_mysql_ResultObject_num_fields__doc__\n\t},\n\t{\n\t\t\"num_rows\",\n\t\t(PyCFunction)_mysql_ResultObject_num_rows,\n\t\tMETH_VARARGS,\n\t\t_mysql_ResultObject_num_rows__doc__\n\t},\n\t{NULL,              NULL} /* sentinel */\n};\n\nstatic MyMemberlist(_mysql_ResultObject_memberlist)[] = {\n\tMyMember(\n\t\t\"converter\",\n\t\tT_OBJECT,\n\t\toffsetof(_mysql_ResultObject,converter),\n\t\tREADONLY,\n\t\t\"Type conversion mapping\"\n\t\t),\n\t{NULL} /* Sentinel */\n};\n\nstatic PyObject *\n_mysql_ConnectionObject_getattr(\n\t_mysql_ConnectionObject *self,\n\tchar *name)\n{\n#ifndef IS_PY3K\n\tPyObject *res;\n\n\tres = Py_FindMethod(_mysql_ConnectionObject_methods, (PyObject *)self, name);\n\tif (res != NULL)\n\t\treturn res;\n\tPyErr_Clear();\n#endif\n\tif (strcmp(name, \"closed\") == 0)\n\t\treturn PyInt_FromLong((long)!(self->open));\n#if PY_VERSION_HEX < 0x02020000\n\treturn PyMember_Get((char *)self, _mysql_ConnectionObject_memberlist, name);\n#else\n\t{\n\t\tMyMemberlist(*l);\n\t\tfor (l = _mysql_ConnectionObject_memberlist; l->name != NULL; l++) {\n\t\t\tif (strcmp(l->name, name) == 0)\n\t\t\t\treturn PyMember_GetOne((char *)self, l);\n\t\t}\n\t\tPyErr_SetString(PyExc_AttributeError, name);\n\t\treturn NULL;\n\t}\n#endif\n}\n\nstatic PyObject *\n_mysql_ResultObject_getattr(\n\t_mysql_ResultObject *self,\n\tchar *name)\n{\n#ifndef IS_PY3K\n\tPyObject *res;\n\n\tres = Py_FindMethod(_mysql_ResultObject_methods, (PyObject *)self, name);\n\tif (res != NULL)\n\t\treturn res;\n\tPyErr_Clear();\n#endif\n#if PY_VERSION_HEX < 0x02020000\n\treturn PyMember_Get((char *)self, _mysql_ResultObject_memberlist, name);\n#else\n\t{\n\t\tMyMemberlist(*l);\n\t\tfor (l = _mysql_ResultObject_memberlist; l->name != NULL; l++) {\n\t\t\tif (strcmp(l->name, name) == 0)\n\t\t\t\treturn PyMember_GetOne((char *)self, l);\n\t\t}\n\t\tPyErr_SetString(PyExc_AttributeError, name);\n\t\treturn NULL;\n\t}\n#endif\n}\n\nstatic int\n_mysql_ConnectionObject_setattr(\n\t_mysql_ConnectionObject *self,\n\tchar *name,\n\tPyObject *v)\n{\n\tif (v == NULL) {\n\t\tPyErr_SetString(PyExc_AttributeError,\n\t\t\t\t\"can't delete connection attributes\");\n\t\treturn -1;\n\t}\n#if PY_VERSION_HEX < 0x02020000\n\treturn PyMember_Set((char *)self, _mysql_ConnectionObject_memberlist, name, v);\n#else\n        {\n\t\tMyMemberlist(*l);\n\t\tfor (l = _mysql_ConnectionObject_memberlist; l->name != NULL; l++)\n\t\t\tif (strcmp(l->name, name) == 0)\n\t\t\t\treturn PyMember_SetOne((char *)self, l, v);\n\t}\n        PyErr_SetString(PyExc_AttributeError, name);\n        return -1;\n#endif\n}\n\nstatic int\n_mysql_ResultObject_setattr(\n\t_mysql_ResultObject *self,\n\tchar *name,\n\tPyObject *v)\n{\n\tif (v == NULL) {\n\t\tPyErr_SetString(PyExc_AttributeError,\n\t\t\t\t\"can't delete connection attributes\");\n\t\treturn -1;\n\t}\n#if PY_VERSION_HEX < 0x02020000\n\treturn PyMember_Set((char *)self, _mysql_ResultObject_memberlist, name, v);\n#else\n        {\n\t\tMyMemberlist(*l);\n\t\tfor (l = _mysql_ResultObject_memberlist; l->name != NULL; l++)\n\t\t\tif (strcmp(l->name, name) == 0)\n\t\t\t\treturn PyMember_SetOne((char *)self, l, v);\n\t}\n        PyErr_SetString(PyExc_AttributeError, name);\n        return -1;\n#endif\n}\n\nPyTypeObject _mysql_ConnectionObject_Type = {\n#ifdef IS_PY3K\n    PyVarObject_HEAD_INIT(NULL, 0)\n#else\n\tPyObject_HEAD_INIT(NULL)\n\t0,\n#endif\n\t\"_mysql.connection\", /* (char *)tp_name For printing */\n\tsizeof(_mysql_ConnectionObject),\n\t0,\n\t(destructor)_mysql_ConnectionObject_dealloc, /* tp_dealloc */\n\t0, /*tp_print*/\n\t(getattrfunc)_mysql_ConnectionObject_getattr, /* tp_getattr */\n\t(setattrfunc)_mysql_ConnectionObject_setattr, /* tp_setattr */\n\t0, /*tp_compare*/\n\t(reprfunc)_mysql_ConnectionObject_repr, /* tp_repr */\n\t\n\t/* Method suites for standard classes */\n\t\n\t0, /* (PyNumberMethods *) tp_as_number */\n\t0, /* (PySequenceMethods *) tp_as_sequence */\n\t0, /* (PyMappingMethods *) tp_as_mapping */\n\t\n\t/* More standard operations (here for binary compatibility) */\n\t\n\t0, /* (hashfunc) tp_hash */\n\t0, /* (ternaryfunc) tp_call */\n\t0, /* (reprfunc) tp_str */\n\t0, /* (getattrofunc) tp_getattro */\n\t0, /* (setattrofunc) tp_setattro */\n\t\n\t/* Functions to access object as input/output buffer */\n\t0, /* (PyBufferProcs *) tp_as_buffer */\n\t\n\t/* Flags to define presence of optional/expanded features */\n#if PY_VERSION_HEX < 0x02020000\n\tPy_TPFLAGS_DEFAULT, /* (long) tp_flags */\n#else\n\tPy_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE,\n#endif\n\t_mysql_connect__doc__, /* (char *) tp_doc Documentation string */\n#if PY_VERSION_HEX >= 0x02000000\t\n\t/* Assigned meaning in release 2.0 */\n#if PY_VERSION_HEX >= 0x02020000\n\t/* call function for all accessible objects */\n\t(traverseproc) _mysql_ConnectionObject_traverse, /* tp_traverse */\n\t\n\t/* delete references to contained objects */\n\t(inquiry) _mysql_ConnectionObject_clear, /* tp_clear */\n#else\n\t/* not supporting pre-2.2 GC */\n\t0,\n\t0,\n#endif\n#if PY_VERSION_HEX >= 0x02010000\t\n\t/* Assigned meaning in release 2.1 */\n\t/* rich comparisons */\n\t0, /* (richcmpfunc) tp_richcompare */\n\t\n\t/* weak reference enabler */\n\t0, /* (long) tp_weaklistoffset */\n#if PY_VERSION_HEX >= 0x02020000\n\t/* Added in release 2.2 */\n\t/* Iterators */\n\t0, /* (getiterfunc) tp_iter */\n\t0, /* (iternextfunc) tp_iternext */\n\t\n\t/* Attribute descriptor and subclassing stuff */\n\t(struct PyMethodDef *)_mysql_ConnectionObject_methods, /* tp_methods */\n\t(MyMemberlist(*))_mysql_ConnectionObject_memberlist, /* tp_members */\n\t0, /* (struct getsetlist *) tp_getset; */\n\t0, /* (struct _typeobject *) tp_base; */\n\t0, /* (PyObject *) tp_dict */\n\t0, /* (descrgetfunc) tp_descr_get */\n\t0, /* (descrsetfunc) tp_descr_set */\n\t0, /* (long) tp_dictoffset */\n\t(initproc)_mysql_ConnectionObject_Initialize, /* tp_init */\n\tNULL, /* tp_alloc */\n\tNULL, /* tp_new */\n\tNULL, /* tp_free Low-level free-memory routine */ \n\t0, /* (PyObject *) tp_bases */\n\t0, /* (PyObject *) tp_mro method resolution order */\n\t0, /* (PyObject *) tp_defined */\n#endif /* python 2.2 */\n#endif /* python 2.1 */\n#endif /* python 2.0 */\n} ;\n\nPyTypeObject _mysql_ResultObject_Type = {\n#ifdef IS_PY3K\n    PyVarObject_HEAD_INIT(NULL, 0)\n#else\n\tPyObject_HEAD_INIT(NULL)\n\t0,\n#endif\n\t\"_mysql.result\",\n\tsizeof(_mysql_ResultObject),\n\t0,\n\t(destructor)_mysql_ResultObject_dealloc, /* tp_dealloc */\n\t0, /*tp_print*/\n\t(getattrfunc)_mysql_ResultObject_getattr, /* tp_getattr */\n\t(setattrfunc)_mysql_ResultObject_setattr, /* tp_setattr */\n\t0, /*tp_compare*/\n\t(reprfunc)_mysql_ResultObject_repr, /* tp_repr */\n\t\n\t/* Method suites for standard classes */\n\t\n\t0, /* (PyNumberMethods *) tp_as_number */\n\t0, /* (PySequenceMethods *) tp_as_sequence */\n\t0, /* (PyMappingMethods *) tp_as_mapping */\n\t\n\t/* More standard operations (here for binary compatibility) */\n\t\n\t0, /* (hashfunc) tp_hash */\n\t0, /* (ternaryfunc) tp_call */\n\t0, /* (reprfunc) tp_str */\n\t0, /* (getattrofunc) tp_getattro */\n\t0, /* (setattrofunc) tp_setattro */\n\t\n\t/* Functions to access object as input/output buffer */\n\t0, /* (PyBufferProcs *) tp_as_buffer */\n\t\n\t/* Flags to define presence of optional/expanded features */\n#if PY_VERSION_HEX < 0x02020000\n\tPy_TPFLAGS_DEFAULT, /* (long) tp_flags */\n#else\n\tPy_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE,\n#endif\n\t\n\t_mysql_ResultObject__doc__, /* (char *) tp_doc Documentation string */\n#if PY_VERSION_HEX >= 0x02000000\t\n\t/* Assigned meaning in release 2.0 */\n#if PY_VERSION_HEX >= 0x02020000\n\t/* call function for all accessible objects */\n\t(traverseproc) _mysql_ResultObject_traverse, /* tp_traverse */\n\t\n\t/* delete references to contained objects */\n\t(inquiry) _mysql_ResultObject_clear, /* tp_clear */\n#else\n\t/* not supporting pre-2.2 GC */\n\t0,\n\t0,\n#endif\n#if PY_VERSION_HEX >= 0x02010000\t\n\t/* Assigned meaning in release 2.1 */\n\t/* rich comparisons */\n\t0, /* (richcmpfunc) tp_richcompare */\n\t\n\t/* weak reference enabler */\n\t0, /* (long) tp_weaklistoffset */\n#if PY_VERSION_HEX >= 0x02020000\n\t/* Added in release 2.2 */\n\t/* Iterators */\n\t0, /* (getiterfunc) tp_iter */\n\t0, /* (iternextfunc) tp_iternext */\n\t\n\t/* Attribute descriptor and subclassing stuff */\n\t(struct PyMethodDef *) _mysql_ResultObject_methods, /* tp_methods */\n\t(MyMemberlist(*)) _mysql_ResultObject_memberlist, /*tp_members */\n\t0, /* (struct getsetlist *) tp_getset; */\n\t0, /* (struct _typeobject *) tp_base; */\n\t0, /* (PyObject *) tp_dict */\n\t0, /* (descrgetfunc) tp_descr_get */\n\t0, /* (descrsetfunc) tp_descr_set */\n\t0, /* (long) tp_dictoffset */\n\t(initproc)_mysql_ResultObject_Initialize, /* tp_init */\n\tNULL, /* tp_alloc */\n\tNULL, /* tp_new */\n\tNULL, /* tp_free Low-level free-memory routine */\n\t0, /* (PyObject *) tp_bases */\n\t0, /* (PyObject *) tp_mro method resolution order */\n\t0, /* (PyObject *) tp_defined */\n#endif /* python 2.2 */\n#endif /* python 2.1 */\n#endif /* python 2.0 */\n};\n\nstatic PyMethodDef\n_mysql_methods[] = {\n\t{ \n\t\t\"connect\",\n\t\t(PyCFunction)_mysql_connect,\n\t\tMETH_VARARGS | METH_KEYWORDS,\n\t\t_mysql_connect__doc__\n\t},\n\t{ \n\t\t\"debug\",\n\t\t(PyCFunction)_mysql_debug, \n\t\tMETH_VARARGS,\n\t\t_mysql_debug__doc__\n\t},\n\t{\n\t\t\"escape\", \n\t\t(PyCFunction)_mysql_escape, \n\t\tMETH_VARARGS,\n\t\t_mysql_escape__doc__\n\t},\n\t{\n\t\t\"escape_sequence\",\n\t\t(PyCFunction)_mysql_escape_sequence,\n\t\tMETH_VARARGS,\n\t\t_mysql_escape_sequence__doc__\n\t},\n\t{\n\t\t\"escape_dict\",\n\t\t(PyCFunction)_mysql_escape_dict,\n\t\tMETH_VARARGS,\n\t\t_mysql_escape_dict__doc__\n\t},\n\t{ \n\t\t\"escape_string\",\n\t\t(PyCFunction)_mysql_escape_string,\n\t\tMETH_VARARGS,\n\t\t_mysql_escape_string__doc__\n\t},\n\t{ \n\t\t\"string_literal\",\n\t\t(PyCFunction)_mysql_string_literal,\n\t\tMETH_VARARGS,\n\t\t_mysql_string_literal__doc__\n\t},\n\t{\n\t\t\"get_client_info\",\n\t\t(PyCFunction)_mysql_get_client_info,\n\t\tMETH_VARARGS,\n\t\t_mysql_get_client_info__doc__\n\t},\n#if MYSQL_VERSION_ID >= 32314\n\t{\n\t\t\"thread_safe\",\n\t\t(PyCFunction)_mysql_thread_safe,\n\t\tMETH_VARARGS,\n\t\t_mysql_thread_safe__doc__\n\t},\n#endif\n\t{\n\t\t\"server_init\",\n\t\t(PyCFunction)_mysql_server_init,\n\t\tMETH_VARARGS | METH_KEYWORDS,\n\t\t_mysql_server_init__doc__\n\t},\n\t{\n\t\t\"server_end\",\n\t\t(PyCFunction)_mysql_server_end,\n\t\tMETH_VARARGS,\n\t\t_mysql_server_end__doc__\n\t},\n\t{NULL, NULL} /* sentinel */\n};\n\nstatic PyObject *\n_mysql_NewException(\n\tPyObject *dict,\n\tPyObject *edict,\n\tchar *name)\n{\n\tPyObject *e;\n\n\tif (!(e = PyDict_GetItemString(edict, name)))\n\t\treturn NULL;\n\tif (PyDict_SetItemString(dict, name, e)) return NULL;\n#ifdef PYPY_VERSION\n\tPy_INCREF(e);\n#endif\n\treturn e;\n}\n\n#define QUOTE(X) _QUOTE(X)\n#define _QUOTE(X) #X\n\nstatic char _mysql___doc__[] =\n\"an adaptation of the MySQL C API (mostly)\\n\\\n\\n\\\nYou probably are better off using MySQLdb instead of using this\\n\\\nmodule directly.\\n\\\n\\n\\\nIn general, renaming goes from mysql_* to _mysql.*. _mysql.connect()\\n\\\nreturns a connection object (MYSQL). Functions which expect MYSQL * as\\n\\\nan argument are now methods of the connection object. A number of things\\n\\\nreturn result objects (MYSQL_RES). Functions which expect MYSQL_RES * as\\n\\\nan argument are now methods of the result object. Deprecated functions\\n\\\n(as of 3.23) are NOT implemented.\\n\\\n\";\n\n#ifdef IS_PY3K\nstatic struct PyModuleDef _mysqlmodule = {\n   PyModuleDef_HEAD_INIT,\n   \"_mysql\",   /* name of module */\n   _mysql___doc__, /* module documentation, may be NULL */\n   -1,       /* size of per-interpreter state of the module,\n                or -1 if the module keeps state in global variables. */\n   _mysql_methods\n};\n\nPyMODINIT_FUNC\nPyInit__mysql(void)\n#else\nDL_EXPORT(void)\ninit_mysql(void)\n#endif\n{\n\tPyObject *dict, *module, *emod, *edict;\n#ifdef IS_PY3K\n    module = PyModule_Create(&_mysqlmodule);\n\tif (!module) return module; /* this really should never happen */\n#else\n\tmodule = Py_InitModule4(\"_mysql\", _mysql_methods, _mysql___doc__,\n\t\t\t\t(PyObject *)NULL, PYTHON_API_VERSION);\n\tif (!module) return; /* this really should never happen */\n#endif\n#ifdef IS_PY3K\n\tPy_TYPE(&_mysql_ConnectionObject_Type) = &PyType_Type;\n\tPy_TYPE(&_mysql_ResultObject_Type) = &PyType_Type;\n#else\n\t_mysql_ConnectionObject_Type.ob_type = &PyType_Type;\n\t_mysql_ResultObject_Type.ob_type = &PyType_Type;\n#endif\n#if PY_VERSION_HEX >= 0x02020000\n\t_mysql_ConnectionObject_Type.tp_alloc = PyType_GenericAlloc;\n\t_mysql_ConnectionObject_Type.tp_new = PyType_GenericNew;\n#ifndef IS_PY3K\n\t_mysql_ConnectionObject_Type.tp_free = _PyObject_GC_Del;\n#endif\n\t_mysql_ResultObject_Type.tp_alloc = PyType_GenericAlloc;\n\t_mysql_ResultObject_Type.tp_new = PyType_GenericNew;\n#ifndef IS_PY3K\n\t_mysql_ResultObject_Type.tp_free = _PyObject_GC_Del;\n#endif\n#endif\n\n\tif (!(dict = PyModule_GetDict(module))) goto error;\n\tif (PyDict_SetItemString(dict, \"version_info\",\n\t\t\t       PyRun_String(QUOTE(version_info), Py_eval_input,\n\t\t\t\t       dict, dict)))\n\t\tgoto error;\n\tif (PyDict_SetItemString(dict, \"__version__\",\n#ifdef IS_PY3K\n\t\t\t       PyUnicode_FromString(QUOTE(__version__))))\n#else\n\t\t\t       PyString_FromString(QUOTE(__version__))))\n#endif\n\t\tgoto error;\n\tif (PyDict_SetItemString(dict, \"connection\",\n\t\t\t       (PyObject *)&_mysql_ConnectionObject_Type))\n\t\tgoto error;\n\tPy_INCREF(&_mysql_ConnectionObject_Type);\n\tif (PyDict_SetItemString(dict, \"result\",\n\t\t\t       (PyObject *)&_mysql_ResultObject_Type))\n\t\tgoto error;\t\n\tPy_INCREF(&_mysql_ResultObject_Type);\n\tif (!(emod = PyImport_ImportModule(\"_mysql_exceptions\"))) {\n\t    PyErr_Print();\n\t\tgoto error;\n\t}\n\tif (!(edict = PyModule_GetDict(emod))) goto error;\n\tif (!(_mysql_MySQLError =\n\t      _mysql_NewException(dict, edict, \"MySQLError\")))\n\t\tgoto error;\n\tif (!(_mysql_Warning =\n\t      _mysql_NewException(dict, edict, \"Warning\")))\n\t\tgoto error;\n\tif (!(_mysql_Error =\n\t      _mysql_NewException(dict, edict, \"Error\")))\n\t\tgoto error;\n\tif (!(_mysql_InterfaceError =\n\t      _mysql_NewException(dict, edict, \"InterfaceError\")))\n\t\tgoto error;\n\tif (!(_mysql_DatabaseError =\n\t      _mysql_NewException(dict, edict, \"DatabaseError\")))\n\t\tgoto error;\n\tif (!(_mysql_DataError =\n\t      _mysql_NewException(dict, edict, \"DataError\")))\n\t\tgoto error;\n\tif (!(_mysql_OperationalError =\n\t      _mysql_NewException(dict, edict, \"OperationalError\")))\n\t\tgoto error;\n\tif (!(_mysql_IntegrityError =\n\t      _mysql_NewException(dict, edict, \"IntegrityError\")))\n\t\tgoto error;\n\tif (!(_mysql_InternalError =\n\t      _mysql_NewException(dict, edict, \"InternalError\")))\n\t\tgoto error;\n\tif (!(_mysql_ProgrammingError =\n\t      _mysql_NewException(dict, edict, \"ProgrammingError\")))\n\t\tgoto error;\n\tif (!(_mysql_NotSupportedError =\n\t      _mysql_NewException(dict, edict, \"NotSupportedError\")))\n\t\tgoto error;\n\tPy_DECREF(emod);\n#ifdef IS_PY3K\n\tif (!(_mysql_NULL = PyUnicode_FromString(\"NULL\")))\n\t\tgoto error;\n#else\n\tif (!(_mysql_NULL = PyString_FromString(\"NULL\")))\n\t\tgoto error;\n#endif\n\tif (PyDict_SetItemString(dict, \"NULL\", _mysql_NULL)) goto error;\n  error:\n\tif (PyErr_Occurred()) {\n\t\tPyErr_SetString(PyExc_ImportError,\n\t\t\t\t\"_mysql: init failed\");\n\t\tmodule = NULL;\n    }\n#ifdef IS_PY3K\n    return module;\n#endif\n}\n\n\n"
  },
  {
    "path": "_mysql_exceptions.py",
    "content": "\"\"\"_mysql_exceptions: Exception classes for _mysql and MySQLdb.\n\nThese classes are dictated by the DB API v2.0:\n\n    http://www.python.org/topics/database/DatabaseAPI-2.0.html\n\"\"\"\n\ntry:\n    from exceptions import Exception, StandardError, Warning\nexcept ImportError:\n    # Python 3\n    StandardError = Exception\n\n\nclass MySQLError(StandardError):\n    \n    \"\"\"Exception related to operation with MySQL.\"\"\"\n\n\nclass Warning(Warning, MySQLError):\n\n    \"\"\"Exception raised for important warnings like data truncations\n    while inserting, etc.\"\"\"\n\nclass Error(MySQLError):\n\n    \"\"\"Exception that is the base class of all other error exceptions\n    (not Warning).\"\"\"\n\n\nclass InterfaceError(Error):\n\n    \"\"\"Exception raised for errors that are related to the database\n    interface rather than the database itself.\"\"\"\n\n\nclass DatabaseError(Error):\n\n    \"\"\"Exception raised for errors that are related to the\n    database.\"\"\"\n\n\nclass DataError(DatabaseError):\n\n    \"\"\"Exception raised for errors that are due to problems with the\n    processed data like division by zero, numeric value out of range,\n    etc.\"\"\"\n\n\nclass OperationalError(DatabaseError):\n\n    \"\"\"Exception raised for errors that are related to the database's\n    operation and not necessarily under the control of the programmer,\n    e.g. an unexpected disconnect occurs, the data source name is not\n    found, a transaction could not be processed, a memory allocation\n    error occurred during processing, etc.\"\"\"\n\n\nclass IntegrityError(DatabaseError):\n\n    \"\"\"Exception raised when the relational integrity of the database\n    is affected, e.g. a foreign key check fails, duplicate key,\n    etc.\"\"\"\n\n\nclass InternalError(DatabaseError):\n\n    \"\"\"Exception raised when the database encounters an internal\n    error, e.g. the cursor is not valid anymore, the transaction is\n    out of sync, etc.\"\"\"\n\n\nclass ProgrammingError(DatabaseError):\n\n    \"\"\"Exception raised for programming errors, e.g. table not found\n    or already exists, syntax error in the SQL statement, wrong number\n    of parameters specified, etc.\"\"\"\n\n\nclass NotSupportedError(DatabaseError):\n\n    \"\"\"Exception raised in case a method or database API was used\n    which is not supported by the database, e.g. requesting a\n    .rollback() on a connection that does not support transaction or\n    has transactions turned off.\"\"\"\n\n\n"
  },
  {
    "path": "doc/FAQ.rst",
    "content": "====================================\n MySQLdb Frequently Asked Questions\n====================================\n\n.. contents::\n..\n\n\nBuild Errors\n------------\n\n  ld: fatal: library -lmysqlclient_r: not found\n\nmysqlclient_r is the thread-safe library. It's not available on\nall platforms, or all installations, apparently. You'll need to\nreconfigure site.cfg (in MySQLdb-1.2.1 and newer) to have\nthreadsafe = False.\n\n  mysql.h: No such file or directory\n\nThis almost always mean you don't have development packages\ninstalled. On some systems, C headers for various things (like MySQL)\nare distributed as a seperate package. You'll need to figure out\nwhat that is and install it, but often the name ends with -devel.\n\nAnother possibility: Some older versions of mysql_config behave oddly\nand may throw quotes around some of the path names, which confused\nMySQLdb-1.2.0. 1.2.1 works around these problems. If you see things\nlike -I'/usr/local/include/mysql' in your compile command, that's\nprobably the issue, but it shouldn't happen any more.\n\n\nImportError\n-----------\n\n  ImportError: No module named _mysql \n\nIf you see this, it's likely you did some wrong when installing\nMySQLdb; re-read (or read) README. _mysql is the low-level C module\nthat interfaces with the MySQL client library.\n\nVarious versions of MySQLdb in the past have had build issues on\n\"weird\" platforms; \"weird\" in this case means \"not Linux\", though\ngenerally there aren't problems on Unix/POSIX platforms, including\nBSDs and Mac OS X. Windows has been more problematic, in part because\nthere is no `mysql_config` available in the Windows installation of\nMySQL. 1.2.1 solves most, if not all, of these problems, but you will\nstill have to edit a configuration file so that the setup knows where\nto find MySQL and what libraries to include.\n\n\n  ImportError: libmysqlclient_r.so.14: cannot open shared object file: No such file or directory \n\nThe number after .so may vary, but this means you have a version of\nMySQLdb compiled against one version of MySQL, and are now trying to\nrun it against a different version. The shared library version tends\nto change between major releases.\n\nSolution: Rebuilt MySQLdb, or get the matching version of MySQL.\n\nAnother thing that can cause this: The MySQL libraries may not be on\nyour system path.\n\nSolutions:\n\n* set the LD_LIBRARY_PATH environment variable so that it includes\n  the path to the MySQL libraries.\n\n* set static=True in site.cfg for static linking\n\n* reconfigure your system so that the MySQL libraries are on the\n  default loader path. In Linux, you edit /etc/ld.so.conf and run\n  ldconfig. For Solaris, see `Linker and Libraries Guide\n  <http://docs.sun.com/app/docs/doc/817-3677/6mj8mbtbe?a=view>`_.\n\n\n  ImportError: ld.so.1: python: fatal: libmtmalloc.so.1: DF_1_NOOPEN tagged object may not be dlopen()'ed \n\nThis is a weird one from Solaris. What does it mean? I have no idea.\nHowever, things like this can happen if there is some sort of a compiler\nor environment mismatch between Python and MySQL. For example, on some\ncommercial systems, you might have some code compiled with their own\ncompiler, and other things compiled with GCC. They don't always mesh\ntogether. One way to encounter this is by getting binary packages from\ndifferent vendors.\n\nSolution: Rebuild Python or MySQL (or maybe both) from source.\n\n  ImportError: dlopen(./_mysql.so, 2): Symbol not found: _sprintf$LDBLStub \n  Referenced from: ./_mysql.so \n  Expected in: dynamic lookup \n\nThis is one from Mac OS X. It seems to have been a compiler mismatch,\nbut this time between two different versions of GCC. It seems nearly\nevery major release of GCC changes the ABI in some why, so linking\ncode compiled with GCC-3.3 and GCC-4.0, for example, can be\nproblematic.\n\n\nMy data disappeared! (or won't go away!)\n----------------------------------------\n\nStarting with 1.2.0, MySQLdb disables autocommit by default, as\nrequired by the DB-API standard (`PEP-249`_). If you are using InnoDB\ntables or some other type of transactional table type, you'll need\nto do connection.commit() before closing the connection, or else\nnone of your changes will be written to the database.\n\nConversely, you can also use connection.rollback() to throw away\nany changes you've made since the last commit.\n\nImportant note: Some SQL statements -- specifically DDL statements\nlike CREATE TABLE -- are non-transactional, so they can't be\nrolled back, and they cause pending transactions to commit.\n\n\nOther Errors\n------------\n\n  OperationalError: (1251, 'Client does not support authentication protocol requested by server; consider upgrading MySQL client')  \n\nThis means your server and client libraries are not the same version.\nMore specifically, it probably means you have a 4.1 or newer server\nand 4.0 or older client. You can either upgrade the client side, or\ntry some of the workarounds in `Password Hashing as of MySQL 4.1\n<http://dev.mysql.com/doc/refman/5.0/en/password-hashing.html>`_.\n\n\nOther Resources\n---------------\n\n* Help forum. Please search before posting.\n\n* `Google <http://www.google.com/>`_\n\n* READ README!\n\n* Read the User's Guide\n\n* Read `PEP-249`_\n\n.. _`PEP-249`: http://www.python.org/peps/pep-0249.html\n\n"
  },
  {
    "path": "doc/Makefile",
    "content": "# Makefile for Sphinx documentation\n#\n\n# You can set these variables from the command line.\nSPHINXOPTS    =\nSPHINXBUILD   = sphinx-build\nPAPER         =\nBUILDDIR      = _build\n\n# Internal variables.\nPAPEROPT_a4     = -D latex_paper_size=a4\nPAPEROPT_letter = -D latex_paper_size=letter\nALLSPHINXOPTS   = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .\n# the i18n builder cannot share the environment and doctrees with the others\nI18NSPHINXOPTS  = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .\n\n.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext\n\nhelp:\n\t@echo \"Please use \\`make <target>' where <target> is one of\"\n\t@echo \"  html       to make standalone HTML files\"\n\t@echo \"  dirhtml    to make HTML files named index.html in directories\"\n\t@echo \"  singlehtml to make a single large HTML file\"\n\t@echo \"  pickle     to make pickle files\"\n\t@echo \"  json       to make JSON files\"\n\t@echo \"  htmlhelp   to make HTML files and a HTML help project\"\n\t@echo \"  qthelp     to make HTML files and a qthelp project\"\n\t@echo \"  devhelp    to make HTML files and a Devhelp project\"\n\t@echo \"  epub       to make an epub\"\n\t@echo \"  latex      to make LaTeX files, you can set PAPER=a4 or PAPER=letter\"\n\t@echo \"  latexpdf   to make LaTeX files and run them through pdflatex\"\n\t@echo \"  text       to make text files\"\n\t@echo \"  man        to make manual pages\"\n\t@echo \"  texinfo    to make Texinfo files\"\n\t@echo \"  info       to make Texinfo files and run them through makeinfo\"\n\t@echo \"  gettext    to make PO message catalogs\"\n\t@echo \"  changes    to make an overview of all changed/added/deprecated items\"\n\t@echo \"  linkcheck  to check all external links for integrity\"\n\t@echo \"  doctest    to run all doctests embedded in the documentation (if enabled)\"\n\nclean:\n\t-rm -rf $(BUILDDIR)/*\n\nhtml:\n\t$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html\n\t@echo\n\t@echo \"Build finished. The HTML pages are in $(BUILDDIR)/html.\"\n\ndirhtml:\n\t$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml\n\t@echo\n\t@echo \"Build finished. The HTML pages are in $(BUILDDIR)/dirhtml.\"\n\nsinglehtml:\n\t$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml\n\t@echo\n\t@echo \"Build finished. The HTML page is in $(BUILDDIR)/singlehtml.\"\n\npickle:\n\t$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle\n\t@echo\n\t@echo \"Build finished; now you can process the pickle files.\"\n\njson:\n\t$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json\n\t@echo\n\t@echo \"Build finished; now you can process the JSON files.\"\n\nhtmlhelp:\n\t$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp\n\t@echo\n\t@echo \"Build finished; now you can run HTML Help Workshop with the\" \\\n\t      \".hhp project file in $(BUILDDIR)/htmlhelp.\"\n\nqthelp:\n\t$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp\n\t@echo\n\t@echo \"Build finished; now you can run \"qcollectiongenerator\" with the\" \\\n\t      \".qhcp project file in $(BUILDDIR)/qthelp, like this:\"\n\t@echo \"# qcollectiongenerator $(BUILDDIR)/qthelp/MySQLdb.qhcp\"\n\t@echo \"To view the help file:\"\n\t@echo \"# assistant -collectionFile $(BUILDDIR)/qthelp/MySQLdb.qhc\"\n\ndevhelp:\n\t$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp\n\t@echo\n\t@echo \"Build finished.\"\n\t@echo \"To view the help file:\"\n\t@echo \"# mkdir -p $$HOME/.local/share/devhelp/MySQLdb\"\n\t@echo \"# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/MySQLdb\"\n\t@echo \"# devhelp\"\n\nepub:\n\t$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub\n\t@echo\n\t@echo \"Build finished. The epub file is in $(BUILDDIR)/epub.\"\n\nlatex:\n\t$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex\n\t@echo\n\t@echo \"Build finished; the LaTeX files are in $(BUILDDIR)/latex.\"\n\t@echo \"Run \\`make' in that directory to run these through (pdf)latex\" \\\n\t      \"(use \\`make latexpdf' here to do that automatically).\"\n\nlatexpdf:\n\t$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex\n\t@echo \"Running LaTeX files through pdflatex...\"\n\t$(MAKE) -C $(BUILDDIR)/latex all-pdf\n\t@echo \"pdflatex finished; the PDF files are in $(BUILDDIR)/latex.\"\n\ntext:\n\t$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text\n\t@echo\n\t@echo \"Build finished. The text files are in $(BUILDDIR)/text.\"\n\nman:\n\t$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man\n\t@echo\n\t@echo \"Build finished. The manual pages are in $(BUILDDIR)/man.\"\n\ntexinfo:\n\t$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo\n\t@echo\n\t@echo \"Build finished. The Texinfo files are in $(BUILDDIR)/texinfo.\"\n\t@echo \"Run \\`make' in that directory to run these through makeinfo\" \\\n\t      \"(use \\`make info' here to do that automatically).\"\n\ninfo:\n\t$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo\n\t@echo \"Running Texinfo files through makeinfo...\"\n\tmake -C $(BUILDDIR)/texinfo info\n\t@echo \"makeinfo finished; the Info files are in $(BUILDDIR)/texinfo.\"\n\ngettext:\n\t$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale\n\t@echo\n\t@echo \"Build finished. The message catalogs are in $(BUILDDIR)/locale.\"\n\nchanges:\n\t$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes\n\t@echo\n\t@echo \"The overview file is in $(BUILDDIR)/changes.\"\n\nlinkcheck:\n\t$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck\n\t@echo\n\t@echo \"Link check complete; look for any errors in the above output \" \\\n\t      \"or in $(BUILDDIR)/linkcheck/output.txt.\"\n\ndoctest:\n\t$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest\n\t@echo \"Testing of doctests in the sources finished, look at the \" \\\n\t      \"results in $(BUILDDIR)/doctest/output.txt.\"\n"
  },
  {
    "path": "doc/MySQLdb.constants.rst",
    "content": "constants Package\r\n=================\r\n\r\n:mod:`constants` Package\r\n------------------------\r\n\r\n.. automodule:: MySQLdb.constants\r\n    :members:\r\n    :undoc-members:\r\n    :show-inheritance:\r\n\r\n:mod:`CLIENT` Module\r\n--------------------\r\n\r\n.. automodule:: MySQLdb.constants.CLIENT\r\n    :members:\r\n    :undoc-members:\r\n    :show-inheritance:\r\n\r\n:mod:`CR` Module\r\n----------------\r\n\r\n.. automodule:: MySQLdb.constants.CR\r\n    :members:\r\n    :undoc-members:\r\n    :show-inheritance:\r\n\r\n:mod:`ER` Module\r\n----------------\r\n\r\n.. automodule:: MySQLdb.constants.ER\r\n    :members:\r\n    :undoc-members:\r\n    :show-inheritance:\r\n\r\n:mod:`FIELD_TYPE` Module\r\n------------------------\r\n\r\n.. automodule:: MySQLdb.constants.FIELD_TYPE\r\n    :members:\r\n    :undoc-members:\r\n    :show-inheritance:\r\n\r\n:mod:`FLAG` Module\r\n------------------\r\n\r\n.. automodule:: MySQLdb.constants.FLAG\r\n    :members:\r\n    :undoc-members:\r\n    :show-inheritance:\r\n\r\n:mod:`REFRESH` Module\r\n---------------------\r\n\r\n.. automodule:: MySQLdb.constants.REFRESH\r\n    :members:\r\n    :undoc-members:\r\n    :show-inheritance:\r\n\r\n"
  },
  {
    "path": "doc/MySQLdb.rst",
    "content": "MySQLdb Package\r\n===============\r\n\r\n:mod:`MySQLdb` Package\r\n----------------------\r\n\r\n.. automodule:: MySQLdb.__init__\r\n    :members:\r\n    :undoc-members:\r\n    :show-inheritance:\r\n\r\n:mod:`connections` Module\r\n-------------------------\r\n\r\n.. automodule:: MySQLdb.connections\r\n    :members: Connection\r\n    :undoc-members:\r\n    :show-inheritance:\r\n\r\n:mod:`converters` Module\r\n------------------------\r\n\r\n.. automodule:: MySQLdb.converters\r\n    :members:\r\n    :undoc-members:\r\n    :show-inheritance:\r\n\r\n:mod:`cursors` Module\r\n---------------------\r\n\r\n.. automodule:: MySQLdb.cursors\r\n    :members: Cursor\r\n    :undoc-members:\r\n    :show-inheritance:\r\n\r\n:mod:`times` Module\r\n-------------------\r\n\r\n.. automodule:: MySQLdb.times\r\n    :members:\r\n    :undoc-members:\r\n    :show-inheritance:\r\n\r\nSubpackages\r\n-----------\r\n\r\n.. toctree::\r\n\r\n    MySQLdb.constants\r\n\r\n"
  },
  {
    "path": "doc/_mysql.rst",
    "content": "_mysql Module\n=============\n\n.. automodule:: _mysql\n    :members:\n    :undoc-members:\n    :show-inheritance:"
  },
  {
    "path": "doc/_mysql_exceptions.rst",
    "content": "_mysql_exceptions Module\r\n========================\r\n\r\n.. automodule:: _mysql_exceptions\r\n    :members:\r\n    :undoc-members:\r\n    :show-inheritance:\r\n"
  },
  {
    "path": "doc/conf.py",
    "content": "# -*- coding: utf-8 -*-\n#\n# MySQLdb documentation build configuration file, created by\n# sphinx-quickstart on Sun Oct 07 19:36:17 2012.\n#\n# This file is execfile()d with the current directory set to its containing dir.\n#\n# Note that not all possible configuration values are present in this\n# autogenerated file.\n#\n# All configuration values have a default; values that are commented out\n# serve to show the default.\n\nimport sys, os\n\n# If extensions (or modules to document with autodoc) are in another directory,\n# add these directories to sys.path here. If the directory is relative to the\n# documentation root, use os.path.abspath to make it absolute, like shown here.\n#sys.path.insert(0, os.path.abspath('.'))\n\n# -- General configuration -----------------------------------------------------\n\n# If your documentation needs a minimal Sphinx version, state it here.\n#needs_sphinx = '1.0'\n\n# Add any Sphinx extension module names here, as strings. They can be extensions\n# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.\nextensions = ['sphinx.ext.autodoc']\n\n# Add any paths that contain templates here, relative to this directory.\ntemplates_path = ['_templates']\n\n# The suffix of source filenames.\nsource_suffix = '.rst'\n\n# The encoding of source files.\n#source_encoding = 'utf-8-sig'\n\n# The master toctree document.\nmaster_doc = 'index'\n\n# General information about the project.\nproject = u'MySQLdb'\ncopyright = u'2012, Andy Dustman'\n\n# The version info for the project you're documenting, acts as replacement for\n# |version| and |release|, also used in various other places throughout the\n# built documents.\n#\n# The short X.Y version.\nversion = '1.2'\n# The full version, including alpha/beta/rc tags.\nrelease = '1.2.4b4'\n\n# The language for content autogenerated by Sphinx. Refer to documentation\n# for a list of supported languages.\n#language = None\n\n# There are two options for replacing |today|: either, you set today to some\n# non-false value, then it is used:\n#today = ''\n# Else, today_fmt is used as the format for a strftime call.\n#today_fmt = '%B %d, %Y'\n\n# List of patterns, relative to source directory, that match files and\n# directories to ignore when looking for source files.\nexclude_patterns = ['_build']\n\n# The reST default role (used for this markup: `text`) to use for all documents.\n#default_role = None\n\n# If true, '()' will be appended to :func: etc. cross-reference text.\n#add_function_parentheses = True\n\n# If true, the current module name will be prepended to all description\n# unit titles (such as .. function::).\n#add_module_names = True\n\n# If true, sectionauthor and moduleauthor directives will be shown in the\n# output. They are ignored by default.\n#show_authors = False\n\n# The name of the Pygments (syntax highlighting) style to use.\npygments_style = 'sphinx'\n\n# A list of ignored prefixes for module index sorting.\n#modindex_common_prefix = []\n\n\n# -- Options for HTML output ---------------------------------------------------\n\n# The theme to use for HTML and HTML Help pages.  See the documentation for\n# a list of builtin themes.\nhtml_theme = 'default'\n\n# Theme options are theme-specific and customize the look and feel of a theme\n# further.  For a list of options available for each theme, see the\n# documentation.\n#html_theme_options = {}\n\n# Add any paths that contain custom themes here, relative to this directory.\n#html_theme_path = []\n\n# The name for this set of Sphinx documents.  If None, it defaults to\n# \"<project> v<release> documentation\".\n#html_title = None\n\n# A shorter title for the navigation bar.  Default is the same as html_title.\n#html_short_title = None\n\n# The name of an image file (relative to this directory) to place at the top\n# of the sidebar.\n#html_logo = None\n\n# The name of an image file (within the static path) to use as favicon of the\n# docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32\n# pixels large.\n#html_favicon = None\n\n# Add any paths that contain custom static files (such as style sheets) here,\n# relative to this directory. They are copied after the builtin static files,\n# so a file named \"default.css\" will overwrite the builtin \"default.css\".\nhtml_static_path = ['_static']\n\n# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,\n# using the given strftime format.\n#html_last_updated_fmt = '%b %d, %Y'\n\n# If true, SmartyPants will be used to convert quotes and dashes to\n# typographically correct entities.\n#html_use_smartypants = True\n\n# Custom sidebar templates, maps document names to template names.\n#html_sidebars = {}\n\n# Additional templates that should be rendered to pages, maps page names to\n# template names.\n#html_additional_pages = {}\n\n# If false, no module index is generated.\n#html_domain_indices = True\n\n# If false, no index is generated.\n#html_use_index = True\n\n# If true, the index is split into individual pages for each letter.\n#html_split_index = False\n\n# If true, links to the reST sources are added to the pages.\n#html_show_sourcelink = True\n\n# If true, \"Created using Sphinx\" is shown in the HTML footer. Default is True.\n#html_show_sphinx = True\n\n# If true, \"(C) Copyright ...\" is shown in the HTML footer. Default is True.\n#html_show_copyright = True\n\n# If true, an OpenSearch description file will be output, and all pages will\n# contain a <link> tag referring to it.  The value of this option must be the\n# base URL from which the finished HTML is served.\n#html_use_opensearch = ''\n\n# This is the file name suffix for HTML files (e.g. \".xhtml\").\n#html_file_suffix = None\n\n# Output file base name for HTML help builder.\nhtmlhelp_basename = 'MySQLdbdoc'\n\n\n# -- Options for LaTeX output --------------------------------------------------\n\nlatex_elements = {\n# The paper size ('letterpaper' or 'a4paper').\n#'papersize': 'letterpaper',\n\n# The font size ('10pt', '11pt' or '12pt').\n#'pointsize': '10pt',\n\n# Additional stuff for the LaTeX preamble.\n#'preamble': '',\n}\n\n# Grouping the document tree into LaTeX files. List of tuples\n# (source start file, target name, title, author, documentclass [howto/manual]).\nlatex_documents = [\n  ('index', 'MySQLdb.tex', u'MySQLdb Documentation',\n   u'Andy Dustman', 'manual'),\n]\n\n# The name of an image file (relative to this directory) to place at the top of\n# the title page.\n#latex_logo = None\n\n# For \"manual\" documents, if this is true, then toplevel headings are parts,\n# not chapters.\n#latex_use_parts = False\n\n# If true, show page references after internal links.\n#latex_show_pagerefs = False\n\n# If true, show URL addresses after external links.\n#latex_show_urls = False\n\n# Documents to append as an appendix to all manuals.\n#latex_appendices = []\n\n# If false, no module index is generated.\n#latex_domain_indices = True\n\n\n# -- Options for manual page output --------------------------------------------\n\n# One entry per manual page. List of tuples\n# (source start file, name, description, authors, manual section).\nman_pages = [\n    ('index', 'mysqldb', u'MySQLdb Documentation',\n     [u'Andy Dustman'], 1)\n]\n\n# If true, show URL addresses after external links.\n#man_show_urls = False\n\n\n# -- Options for Texinfo output ------------------------------------------------\n\n# Grouping the document tree into Texinfo files. List of tuples\n# (source start file, target name, title, author,\n#  dir menu entry, description, category)\ntexinfo_documents = [\n  ('index', 'MySQLdb', u'MySQLdb Documentation',\n   u'Andy Dustman', 'MySQLdb', 'One line description of project.',\n   'Miscellaneous'),\n]\n\n# Documents to append as an appendix to all manuals.\n#texinfo_appendices = []\n\n# If false, no module index is generated.\n#texinfo_domain_indices = True\n\n# How to display URL addresses: 'footnote', 'no', or 'inline'.\n#texinfo_show_urls = 'footnote'\n"
  },
  {
    "path": "doc/index.rst",
    "content": ".. MySQLdb documentation master file, created by\n   sphinx-quickstart on Sun Oct 07 19:36:17 2012.\n   You can adapt this file completely to your liking, but it should at least\n   contain the root `toctree` directive.\n\nWelcome to MySQLdb's documentation!\n===================================\n\nContents:\n\n.. toctree::\n    :maxdepth: 3\n\n    user_guide\n    MySQLdb\n    FAQ\n\nIndices and tables\n==================\n\n* :ref:`genindex`\n* :ref:`modindex`\n* :ref:`search`\n\n"
  },
  {
    "path": "doc/make.bat",
    "content": "@ECHO OFF\n\nREM Command file for Sphinx documentation\n\nif \"%SPHINXBUILD%\" == \"\" (\n\tset SPHINXBUILD=sphinx-build\n)\nset BUILDDIR=_build\nset ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .\nset I18NSPHINXOPTS=%SPHINXOPTS% .\nif NOT \"%PAPER%\" == \"\" (\n\tset ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%\n\tset I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS%\n)\n\nif \"%1\" == \"\" goto help\n\nif \"%1\" == \"help\" (\n\t:help\n\techo.Please use `make ^<target^>` where ^<target^> is one of\n\techo.  html       to make standalone HTML files\n\techo.  dirhtml    to make HTML files named index.html in directories\n\techo.  singlehtml to make a single large HTML file\n\techo.  pickle     to make pickle files\n\techo.  json       to make JSON files\n\techo.  htmlhelp   to make HTML files and a HTML help project\n\techo.  qthelp     to make HTML files and a qthelp project\n\techo.  devhelp    to make HTML files and a Devhelp project\n\techo.  epub       to make an epub\n\techo.  latex      to make LaTeX files, you can set PAPER=a4 or PAPER=letter\n\techo.  text       to make text files\n\techo.  man        to make manual pages\n\techo.  texinfo    to make Texinfo files\n\techo.  gettext    to make PO message catalogs\n\techo.  changes    to make an overview over all changed/added/deprecated items\n\techo.  linkcheck  to check all external links for integrity\n\techo.  doctest    to run all doctests embedded in the documentation if enabled\n\tgoto end\n)\n\nif \"%1\" == \"clean\" (\n\tfor /d %%i in (%BUILDDIR%\\*) do rmdir /q /s %%i\n\tdel /q /s %BUILDDIR%\\*\n\tgoto end\n)\n\nif \"%1\" == \"html\" (\n\t%SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Build finished. The HTML pages are in %BUILDDIR%/html.\n\tgoto end\n)\n\nif \"%1\" == \"dirhtml\" (\n\t%SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.\n\tgoto end\n)\n\nif \"%1\" == \"singlehtml\" (\n\t%SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml.\n\tgoto end\n)\n\nif \"%1\" == \"pickle\" (\n\t%SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Build finished; now you can process the pickle files.\n\tgoto end\n)\n\nif \"%1\" == \"json\" (\n\t%SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Build finished; now you can process the JSON files.\n\tgoto end\n)\n\nif \"%1\" == \"htmlhelp\" (\n\t%SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Build finished; now you can run HTML Help Workshop with the ^\n.hhp project file in %BUILDDIR%/htmlhelp.\n\tgoto end\n)\n\nif \"%1\" == \"qthelp\" (\n\t%SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Build finished; now you can run \"qcollectiongenerator\" with the ^\n.qhcp project file in %BUILDDIR%/qthelp, like this:\n\techo.^> qcollectiongenerator %BUILDDIR%\\qthelp\\MySQLdb.qhcp\n\techo.To view the help file:\n\techo.^> assistant -collectionFile %BUILDDIR%\\qthelp\\MySQLdb.ghc\n\tgoto end\n)\n\nif \"%1\" == \"devhelp\" (\n\t%SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Build finished.\n\tgoto end\n)\n\nif \"%1\" == \"epub\" (\n\t%SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Build finished. The epub file is in %BUILDDIR%/epub.\n\tgoto end\n)\n\nif \"%1\" == \"latex\" (\n\t%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Build finished; the LaTeX files are in %BUILDDIR%/latex.\n\tgoto end\n)\n\nif \"%1\" == \"text\" (\n\t%SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Build finished. The text files are in %BUILDDIR%/text.\n\tgoto end\n)\n\nif \"%1\" == \"man\" (\n\t%SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Build finished. The manual pages are in %BUILDDIR%/man.\n\tgoto end\n)\n\nif \"%1\" == \"texinfo\" (\n\t%SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo.\n\tgoto end\n)\n\nif \"%1\" == \"gettext\" (\n\t%SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Build finished. The message catalogs are in %BUILDDIR%/locale.\n\tgoto end\n)\n\nif \"%1\" == \"changes\" (\n\t%SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.The overview file is in %BUILDDIR%/changes.\n\tgoto end\n)\n\nif \"%1\" == \"linkcheck\" (\n\t%SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Link check complete; look for any errors in the above output ^\nor in %BUILDDIR%/linkcheck/output.txt.\n\tgoto end\n)\n\nif \"%1\" == \"doctest\" (\n\t%SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Testing of doctests in the sources finished, look at the ^\nresults in %BUILDDIR%/doctest/output.txt.\n\tgoto end\n)\n\n:end\n"
  },
  {
    "path": "doc/modules.rst",
    "content": "MySQLdb\r\n=======\r\n\r\n.. toctree::\r\n   :maxdepth: 4\r\n\r\n   MySQLdb\r\n"
  },
  {
    "path": "doc/user_guide.rst",
    "content": "====================\nMySQLdb User's Guide\n====================\n\n.. contents::\n..\n\nIntroduction\n------------\n\nMySQLdb is an thread-compatible interface to the popular MySQL\ndatabase server that provides the Python database API.\n\nInstallation\n------------\n\nThe ``README`` file has complete installation instructions.\n\n\n_mysql\n------\n\nIf you want to write applications which are portable across databases,\nuse MySQLdb_, and avoid using this module directly. ``_mysql``\nprovides an interface which mostly implements the MySQL C API. For\nmore information, see the `MySQL documentation`_. The documentation\nfor this module is intentionally weak because you probably should use\nthe higher-level MySQLdb module. If you really need it, use the\nstandard MySQL docs and transliterate as necessary.\n\n.. _`MySQL documentation`: http://dev.mysql.com/doc/\n\n\nMySQL C API translation\n.......................\n\nThe MySQL C API has been wrapped in an object-oriented way. The only\nMySQL data structures which are implemented are the ``MYSQL``\n(database connection handle) and ``MYSQL_RES`` (result handle)\ntypes. In general, any function which takes ``MYSQL *mysql`` as an\nargument is now a method of the connection object, and any function\nwhich takes ``MYSQL_RES *result`` as an argument is a method of the\nresult object. Functions requiring none of the MySQL data structures\nare implemented as functions in the module. Functions requiring one of\nthe other MySQL data structures are generally not implemented.\nDeprecated functions are not implemented. In all cases, the ``mysql_``\nprefix is dropped from the name. Most of the ``conn`` methods listed\nare also available as MySQLdb Connection object methods. Their use is\nnon-portable.\n\nMySQL C API function mapping\n............................\n\n=================================== ==================================\n      C API                         ``_mysql``\n=================================== ==================================\n ``mysql_affected_rows()``          ``conn.affected_rows()``\n ``mysql_autocommit()``\t\t    ``conn.autocommit()`` \n ``mysql_character_set_name()``\t    ``conn.character_set_name()``\n ``mysql_close()``                  ``conn.close()`` \n ``mysql_commit()``\t\t    ``conn.commit()``\n ``mysql_connect()``\t\t    ``_mysql.connect()`` \n ``mysql_data_seek()``\t\t    ``result.data_seek()`` \n ``mysql_debug()``\t\t    ``_mysql.debug()`` \n ``mysql_dump_debug_info``\t    ``conn.dump_debug_info()`` \n ``mysql_escape_string()``\t    ``_mysql.escape_string()`` \n ``mysql_fetch_row()``\t\t    ``result.fetch_row()`` \n ``mysql_get_character_set_info()`` ``conn.get_character_set_info()``\n ``mysql_get_client_info()``\t    ``_mysql.get_client_info()``\n ``mysql_get_host_info()``\t    ``conn.get_host_info()`` \n ``mysql_get_proto_info()``\t    ``conn.get_proto_info()`` \n ``mysql_get_server_info()``\t    ``conn.get_server_info()`` \n ``mysql_info()``\t\t    ``conn.info()`` \n ``mysql_insert_id()``\t\t    ``conn.insert_id()`` \n ``mysql_num_fields()``\t\t    ``result.num_fields()`` \n ``mysql_num_rows()``\t\t    ``result.num_rows()`` \n ``mysql_options()``\t\t    various options to ``_mysql.connect()`` \n ``mysql_ping()``\t\t    ``conn.ping()`` \n ``mysql_query()``\t\t    ``conn.query()`` \n ``mysql_real_connect()``\t    ``_mysql.connect()`` \n ``mysql_real_query()``\t\t    ``conn.query()`` \n ``mysql_real_escape_string()``\t    ``conn.escape_string()`` \n ``mysql_rollback()``\t\t    ``conn.rollback()``\n ``mysql_row_seek()``\t\t    ``result.row_seek()`` \n ``mysql_row_tell()``\t\t    ``result.row_tell()`` \n ``mysql_select_db()``\t\t    ``conn.select_db()`` \n ``mysql_set_character_set()``\t    ``conn.set_character_set()``\n ``mysql_ssl_set()``                ``ssl`` option to ``_mysql.connect()``\n ``mysql_stat()``\t\t    ``conn.stat()`` \n ``mysql_store_result()``\t    ``conn.store_result()`` \n ``mysql_thread_id()``\t\t    ``conn.thread_id()`` \n ``mysql_thread_safe_client()``\t    ``conn.thread_safe_client()`` \n ``mysql_use_result()``\t\t    ``conn.use_result()``\n ``mysql_warning_count()``          ``conn.warning_count()`` \n ``CLIENT_*``\t\t\t    ``MySQLdb.constants.CLIENT.*`` \n ``CR_*``\t\t\t    ``MySQLdb.constants.CR.*`` \n ``ER_*``\t\t\t    ``MySQLdb.constants.ER.*`` \n ``FIELD_TYPE_*``\t\t    ``MySQLdb.constants.FIELD_TYPE.*`` \n ``FLAG_*``\t\t\t    ``MySQLdb.constants.FLAG.*`` \n=================================== ==================================\n\n\nSome _mysql examples\n....................\n\nOkay, so you want to use ``_mysql`` anyway. Here are some examples.\n\nThe simplest possible database connection is::\n\n    import _mysql\n    db=_mysql.connect()\n\nThis creates a connection to the MySQL server running on the local\nmachine using the standard UNIX socket (or named pipe on Windows),\nyour login name (from the USER environment variable), no password, and\ndoes not ``USE`` a database.  Chances are you need to supply more\ninformation.::\n\n    db=_mysql.connect(\"localhost\",\"joebob\",\"moonpie\",\"thangs\")\n\nThis creates a connection to the MySQL server running on the local\nmachine via a UNIX socket (or named pipe), the user name \"joebob\", the\npassword \"moonpie\", and selects the initial database \"thangs\".\n\nWe haven't even begun to touch upon all the parameters ``connect()``\ncan take.  For this reason, I prefer to use keyword parameters::\n\n    db=_mysql.connect(host=\"localhost\",user=\"joebob\",\n\t              passwd=\"moonpie\",db=\"thangs\")\n\nThis does exactly what the last example did, but is arguably easier to\nread. But since the default host is \"localhost\", and if your login\nname really was \"joebob\", you could shorten it to this::\n\n    db=_mysql.connect(passwd=\"moonpie\",db=\"thangs\")\n\nUNIX sockets and named pipes don't work over a network, so if you\nspecify a host other than localhost, TCP will be used, and you can\nspecify an odd port if you need to (the default port is 3306)::\n\n    db=_mysql.connect(host=\"outhouse\",port=3307,passwd=\"moonpie\",db=\"thangs\")\n\nIf you really had to, you could connect to the local host with TCP by\nspecifying the full host name, or 127.0.0.1.\n\nGenerally speaking, putting passwords in your code is not such a good\nidea::\n\n    db=_mysql.connect(host=\"outhouse\",db=\"thangs\",read_default_file=\"~/.my.cnf\")\n\nThis does what the previous example does, but gets the username and\npassword and other parameters from ~/.my.cnf (UNIX-like systems). Read\nabout `option files`_ for more details.\n\n.. _`option files`: http://dev.mysql.com/doc/mysql/en/Option_files.html\n\nSo now you have an open connection as ``db`` and want to do a\nquery. Well, there are no cursors in MySQL, and no parameter\nsubstitution, so you have to pass a complete query string to\n``db.query()``::\n\n    db.query(\"\"\"SELECT spam, eggs, sausage FROM breakfast\n             WHERE price < 5\"\"\")\n\nThere's no return value from this, but exceptions can be raised. The\nexceptions are defined in a separate module, ``_mysql_exceptions``,\nbut ``_mysql`` exports them. Read DB API specification PEP-249_ to\nfind out what they are, or you can use the catch-all ``MySQLError``.\n\n.. _PEP-249: http://www.python.org/peps/pep-0249.html\n\nAt this point your query has been executed and you need to get the\nresults. You have two options::\n\n    r=db.store_result()\n    # ...or...\n    r=db.use_result()\n\nBoth methods return a result object. What's the difference?\n``store_result()`` returns the entire result set to the client\nimmediately. If your result set is really large, this could be a\nproblem. One way around this is to add a ``LIMIT`` clause to your\nquery, to limit the number of rows returned. The other is to use\n``use_result()``, which keeps the result set in the server and sends\nit row-by-row when you fetch. This does, however, tie up server\nresources, and it ties up the connection: You cannot do any more\nqueries until you have fetched **all** the rows. Generally I\nrecommend using ``store_result()`` unless your result set is really\nhuge and you can't use ``LIMIT`` for some reason.\n\nNow, for actually getting real results::\n\n    >>> r.fetch_row()\n    (('3','2','0'),)\n\nThis might look a little odd. The first thing you should know is,\n``fetch_row()`` takes some additional parameters. The first one is,\nhow many rows (``maxrows``) should be returned. By default, it returns\none row. It may return fewer rows than you asked for, but never\nmore. If you set ``maxrows=0``, it returns all rows of the result\nset. If you ever get an empty tuple back, you ran out of rows.\n\nThe second parameter (``how``) tells it how the row should be\nrepresented. By default, it is zero which means, return as a tuple.\n``how=1`` means, return it as a dictionary, where the keys are the\ncolumn names, or ``table.column`` if there are two columns with the\nsame name (say, from a join). ``how=2`` means the same as ``how=1``\nexcept that the keys are *always* ``table.column``; this is for\ncompatibility with the old ``Mysqldb`` module.\n\nOK, so why did we get a 1-tuple with a tuple inside? Because we\nimplicitly asked for one row, since we didn't specify ``maxrows``.\n\nThe other oddity is: Assuming these are numeric columns, why are they\nreturned as strings? Because MySQL returns all data as strings and\nexpects you to convert it yourself. This would be a real pain in the\nass, but in fact, ``_mysql`` can do this for you. (And ``MySQLdb``\ndoes do this for you.) To have automatic type conversion done, you\nneed to create a type converter dictionary, and pass this to\n``connect()`` as the ``conv`` keyword parameter.\n\nThe keys of ``conv`` should be MySQL column types, which in the\nC API are ``FIELD_TYPE_*``. You can get these values like this::\n\n    from MySQLdb.constants import FIELD_TYPE\n\nBy default, any column type that can't be found in ``conv`` is\nreturned as a string, which works for a lot of stuff. For our\npurposes, we probably want this::\n\n    my_conv = { FIELD_TYPE.LONG: int }\n\nThis means, if it's a ``FIELD_TYPE_LONG``, call the builtin ``int()``\nfunction on it.  Note that ``FIELD_TYPE_LONG`` is an ``INTEGER``\ncolumn, which corresponds to a C ``long``, which is also the type used\nfor a normal Python integer. But beware: If it's really an ``UNSIGNED\nINTEGER`` column, this could cause overflows. For this reason,\n``MySQLdb`` actually uses ``long()`` to do the conversion. But we'll\nignore this potential problem for now.\n\nThen if you use ``db=_mysql.connect(conv=my_conv...)``, the\nresults will come back ``((3, 2, 0),)``, which is what you would\nexpect.\n\nMySQLdb\n-------\n\nMySQLdb is a thin Python wrapper around ``_mysql`` which makes it\ncompatible with the Python DB API interface (version 2).  In reality,\na fair amount of the code which implements the API is in ``_mysql``\nfor the sake of efficiency.\n\nThe DB API specification PEP-249_ should be your primary guide for\nusing this module. Only deviations from the spec and other\ndatabase-dependent things will be documented here.\n\nFunctions and attributes\n........................\n\nOnly a few top-level functions and attributes are defined within\nMySQLdb.\n\nconnect(parameters...)  \n\t Constructor for creating a connection to the\n\t database. Returns a Connection Object. Parameters are the\n\t same as for the MySQL C API.  In addition, there are a few\n\t additional keywords that correspond to what you would pass\n\t ``mysql_options()`` before connecting. Note that some\n\t parameters must be specified as keyword arguments! The\n\t default value for each parameter is NULL or zero, as\n\t appropriate. Consult the MySQL documentation for more\n\t details. The important parameters are:\n\n         host\n            name of host to connect to. Default: use the local host \n            via a UNIX socket (where applicable)\n\n         user\n            user to authenticate as. Default: current effective user.\n\n         passwd\n            password to authenticate with. Default: no password.\n\n         db\n            database to use. Default: no default database.\n\n\t port\n\t    TCP port of MySQL server. Default: standard port (3306).\n\n         unix_socket\n\t    location of UNIX socket. Default: use default location or\n            TCP for remote hosts.\n\n         conv\n            type conversion dictionary.  Default: a copy of\n            ``MySQLdb.converters.conversions``\n\n         compress\n            Enable protocol compression. Default: no compression.\n\n         connect_timeout\n            Abort if connect is not completed within\n            given number of seconds. Default: no timeout (?)\n\n         named_pipe\n            Use a named pipe (Windows). Default: don't.\n\n         init_command\n            Initial command to issue to server upon\n            connection. Default: Nothing.\n\n         read_default_file\n            MySQL configuration file to read; see\n            the MySQL documentation for ``mysql_options()``.\n\n         read_default_group\n            Default group to read; see the MySQL\n            documentation for ``mysql_options()``.\n\n         cursorclass\n            cursor class that ``cursor()`` uses, unless\n            overridden. Default: ``MySQLdb.cursors.Cursor``.  *This\n            must be a keyword parameter.*\n\n         use_unicode\n            If True, CHAR and VARCHAR and TEXT columns are returned as\n            Unicode strings, using the configured character set. It is\n            best to set the default encoding in the server\n            configuration, or client configuration (read with\n            read_default_file).  If you change the character set after\n            connecting (MySQL-4.1 and later), you'll need to put the\n            correct character set name in connection.charset.\n\n\t    If False, text-like columns are returned as normal strings,\n\t    but you can always write Unicode strings.\n\n\t    *This must be a keyword parameter.*\n\n\t charset\n\t    If present, the connection character set will be changed\n\t    to this character set, if they are not equal. Support for\n\t    changing the character set requires MySQL-4.1 and later\n\t    server; if the server is too old, UnsupportedError will be\n\t    raised. This option implies use_unicode=True, but you can\n\t    override this with use_unicode=False, though you probably\n\t    shouldn't.\n\n\t    If not present, the default character set is used.\n\n\t    *This must be a keyword parameter.*\n\n\t sql_mode\n\t    If present, the session SQL mode will be set to the given\n\t    string. For more information on sql_mode, see the MySQL\n\t    documentation. Only available for 4.1 and newer servers.\n\n\t    If not present, the session SQL mode will be unchanged.\n\n\t    *This must be a keyword parameter.*\n\n\t ssl\n\t    This parameter takes a dictionary or mapping, where the\n\t    keys are parameter names used by the mysql_ssl_set_ MySQL\n\t    C API call. If this is set, it initiates an SSL connection\n\t    to the server; if there is no SSL support in the client,\n\t    an exception is raised. *This must be a keyword\n\t    parameter.*\n\n.. _mysql_ssl_set: http://dev.mysql.com/doc/mysql/en/mysql_ssl_set.html\n\n\napilevel \n      String constant stating the supported DB API level. '2.0'\n\nthreadsafety\n      Integer constant stating the level of thread safety the\n      interface supports. This is set to 1, which means: Threads may\n      share the module.\n\n      The MySQL protocol can not handle multiple threads using the\n      same connection at once. Some earlier versions of MySQLdb\n      utilized locking to achieve a threadsafety of 2. While this is\n      not terribly hard to accomplish using the standard Cursor class\n      (which uses ``mysql_store_result()``), it is complicated by\n      SSCursor (which uses ``mysql_use_result()``; with the latter you\n      must ensure all the rows have been read before another query can\n      be executed.  It is further complicated by the addition of\n      transactions, since transactions start when a cursor execute a\n      query, but end when ``COMMIT`` or ``ROLLBACK`` is executed by\n      the Connection object.  Two threads simply cannot share a\n      connection while a transaction is in progress, in addition to\n      not being able to share it during query execution. This\n      excessively complicated the code to the point where it just\n      isn't worth it.\n\n      The general upshot of this is: Don't share connections between\n      threads. It's really not worth your effort or mine, and in the\n      end, will probably hurt performance, since the MySQL server runs\n      a separate thread for each connection.  You can certainly do\n      things like cache connections in a pool, and give those\n      connections to one thread at a time. If you let two threads use\n      a connection simultaneously, the MySQL client library will\n      probably upchuck and die.  You have been warned.\n\n      For threaded applications, try using a connection pool.\n      This can be done using the `Pool module`_.\n\n      .. _`Pool module`: http://dustman.net/andy/python/Pool\n\ncharset\n      The character set used by the connection. In MySQL-4.1 and newer,\n      it is possible (but not recommended) to change the connection's\n      character set with an SQL statement. If you do this, you'll also\n      need to change this attribute. Otherwise, you'll get encoding\n      errors.\n\nparamstyle\n      String constant stating the type of parameter marker formatting\n      expected by the interface. Set to 'format' = ANSI C printf\n      format codes, e.g. '...WHERE name=%s'. If a mapping object is\n      used for conn.execute(), then the interface actually uses\n      'pyformat' = Python extended format codes, e.g. '...WHERE\n      name=%(name)s'. However, the API does not presently allow the\n      specification of more than one style in paramstyle.\n\n      Note that any literal percent signs in the query string passed\n      to execute() must be escaped, i.e. %%.\n\n      Parameter placeholders can **only** be used to insert column\n      values. They can **not** be used for other parts of SQL, such as\n      table names, statements, etc.\n\nconv\n      A dictionary or mapping which controls how types are converted\n      from MySQL to Python and vice versa.\n\n      If the key is a MySQL type (from ``FIELD_TYPE.*``), then the value\n      can be either:\n\n      * a callable object which takes a string argument (the MySQL\n        value),' returning a Python value\n\n      * a sequence of 2-tuples, where the first value is a combination\n\tof flags from ``MySQLdb.constants.FLAG``, and the second value\n\tis a function as above. The sequence is tested until the flags\n\ton the field match those of the first value. If both values\n\tare None, then the default conversion is done. Presently this\n\tis only used to distinquish TEXT and BLOB columns.\n\n      If the key is a Python type or class, then the value is a\n      callable Python object (usually a function) taking two arguments\n      (value to convert, and the conversion dictionary) which converts\n      values of this type to a SQL literal string value.\n\n      This is initialized with reasonable defaults for most\n      types. When creating a Connection object, you can pass your own\n      type converter dictionary as a keyword parameter. Otherwise, it\n      uses a copy of ``MySQLdb.converters.conversions``.  Several\n      non-standard types are returned as strings, which is how MySQL\n      returns all columns. For more details, see the built-in module\n      documentation.\n\n\nConnection Objects\n..................\n\nConnection objects are returned by the ``connect()`` function.\n\ncommit()\n      If the database and the tables support transactions, this\n      commits the current transaction; otherwise this method\n      successfully does nothing.\n\nrollback()\n      If the database and tables support transactions, this rolls back\n      (cancels) the current transaction; otherwise a\n      ``NotSupportedError`` is raised.\n\ncursor([cursorclass])\n      MySQL does not support cursors; however, cursors are easily\n      emulated.  You can supply an alternative cursor class as an\n      optional parameter.  If this is not present, it defaults to the\n      value given when creating the connection object, or the standard\n      ``Cursor`` class. Also see the additional supplied cursor\n      classes in the usage section.\n\nThere are many more methods defined on the connection object which\nare MySQL-specific. For more information on them, consult the internal\ndocumentation using ``pydoc``.\n\n\nCursor Objects\n..............\n\ncallproc(procname, args)\n      Calls stored procedure procname with the sequence of arguments\n      in args. Returns the original arguments. Stored procedure\n      support only works with MySQL-5.0 and newer.\n\n      **Compatibility note:** PEP-249_ specifies that if there are\n      OUT or INOUT parameters, the modified values are to be\n      returned. This is not consistently possible with MySQL. Stored\n      procedure arguments must be passed as server variables, and\n      can only be returned with a SELECT statement. Since a stored\n      procedure may return zero or more result sets, it is impossible\n      for MySQLdb to determine if there are result sets to fetch\n      before the modified parmeters are accessible.\n\n      The parameters are stored in the server as @_*procname*_*n*,\n      where *n* is the position of the parameter. I.e., if you\n      cursor.callproc('foo', (a, b, c)), the parameters will be\n      accessible by a SELECT statement as @_foo_0, @_foo_1, and\n      @_foo_2.\n\n      **Compatibility note:** It appears that the mere act of\n      executing the CALL statement produces an empty result set, which\n      appears after any result sets which might be generated by the\n      stored procedure. Thus, you will always need to use nextset() to\n      advance result sets.\n\nclose()\n      Closes the cursor. Future operations raise ``ProgrammingError``.\n      If you are using server-side cursors, it is very important to\n      close the cursor when you are done with it and before creating a\n      new one.\n\ninfo()\n      Returns some information about the last query. Normally\n      you don't need to check this. If there are any MySQL \n      warnings, it will cause a Warning to be issued through\n      the Python warning module. By default, Warning causes a\n      message to appear on the console. However, it is possible\n      to filter these out or cause Warning to be raised as exception.\n      See the MySQL docs for ``mysql_info()``, and the Python warning\n      module. (Non-standard)\n\nsetinputsizes()\n      Does nothing, successfully.\n\nsetoutputsizes()\n      Does nothing, successfully.\n\nnextset()\n      Advances the cursor to the next result set, discarding the remaining\n      rows in the current result set. If there are no additional result\n      sets, it returns None; otherwise it returns a true value.\n\n      Note that MySQL doesn't support multiple result sets until 4.1.\n      \n\nSome examples\n.............\n\nThe ``connect()`` method works nearly the same as with `_mysql`_::\n\n    import MySQLdb\n    db=MySQLdb.connect(passwd=\"moonpie\",db=\"thangs\")\n\nTo perform a query, you first need a cursor, and then you can execute\nqueries on it::\n\n    c=db.cursor()\n    max_price=5\n    c.execute(\"\"\"SELECT spam, eggs, sausage FROM breakfast\n              WHERE price < %s\"\"\", (max_price,))\n\nIn this example, ``max_price=5`` Why, then, use ``%s`` in the\nstring? Because MySQLdb will convert it to a SQL literal value, which\nis the string '5'. When it's finished, the query will actually say,\n\"...WHERE price < 5\".\n\nWhy the tuple? Because the DB API requires you to pass in any\nparameters as a sequence. Due to the design of the parser, (max_price)\nis interpreted as using algebraic grouping and simply as max_price and\nnot a tuple. Adding a comma, i.e. (max_price,) forces it to make a\ntuple.\n\nAnd now, the results::\n\n    >>> c.fetchone()\n    (3L, 2L, 0L)\n\nQuite unlike the ``_mysql`` example, this returns a single tuple,\nwhich is the row, and the values are properly converted by default...\nexcept... What's with the L's?\n\nAs mentioned earlier, while MySQL's INTEGER column translates\nperfectly into a Python integer, UNSIGNED INTEGER could overflow, so\nthese values are converted to Python long integers instead.\n\nIf you wanted more rows, you could use ``c.fetchmany(n)`` or\n``c.fetchall()``. These do exactly what you think they do. On\n``c.fetchmany(n)``, the ``n`` is optional and defaults to\n``c.arraysize``, which is normally 1. Both of these methods return a\nsequence of rows, or an empty sequence if there are no more rows.  If\nyou use a weird cursor class, the rows themselves might not be tuples.\n\nNote that in contrast to the above, ``c.fetchone()`` returns ``None``\nwhen there are no more rows to fetch.\n\nThe only other method you are very likely to use is when you have to\ndo a multi-row insert::\n\n   c.executemany(\n\t \"\"\"INSERT INTO breakfast (name, spam, eggs, sausage, price)\n\t VALUES (%s, %s, %s, %s, %s)\"\"\",\n\t [\n\t (\"Spam and Sausage Lover's Plate\", 5, 1, 8, 7.95 ),\n\t (\"Not So Much Spam Plate\", 3, 2, 0, 3.95 ),\n\t (\"Don't Wany ANY SPAM! Plate\", 0, 4, 3, 5.95 )\n\t ] )\n\nHere we are inserting three rows of five values. Notice that there is\na mix of types (strings, ints, floats) though we still only use\n``%s``. And also note that we only included format strings for one\nrow. MySQLdb picks those out and duplicates them for each row.\n\nUsing and extending\n-------------------\n\nIn general, it is probably wise to not directly interact with the DB\nAPI except for small applicatons. Databases, even SQL databases, vary\nwidely in capabilities and may have non-standard features. The DB API\ndoes a good job of providing a reasonably portable interface but some\nmethods are non-portable. Specifically, the parameters accepted by\n``connect()`` are completely implementation-dependent.\n\nIf you believe your application may need to run on several different\ndatabases, the author recommends the following approach, based on\npersonal experience: Write a simplified API for your application which\nimplements the specific queries and operations your application needs\nto perform. Implement this API as a base class which should be have\nfew database dependencies, and then derive a subclass from this which\nimplements the necessary dependencies. In this way, porting your\napplication to a new database should be a relatively simple matter of\ncreating a new subclass, assuming the new database is reasonably\nstandard.\n\nBecause MySQLdb's Connection and Cursor objects are written in Python,\nyou can easily derive your own subclasses. There are several Cursor\nclasses in MySQLdb.cursors:\n\nBaseCursor\n    The base class for Cursor objects.  This does not raise Warnings.\n\nCursorStoreResultMixIn\n    Causes the Cursor to use the ``mysql_store_result()`` function to\n    get the query result. The entire result set is stored on the\n    client side.\n\nCursorUseResultMixIn\n    Causes the cursor to use the ``mysql_use_result()`` function to\n    get the query result. The result set is stored on the server side\n    and is transferred row by row using fetch operations.\n\nCursorTupleRowsMixIn\n    Causes the cursor to return rows as a tuple of the column values.\n\nCursorDictRowsMixIn\n\n    Causes the cursor to return rows as a dictionary, where the keys\n    are column names and the values are column values. Note that if\n    the column names are not unique, i.e., you are selecting from two\n    tables that share column names, some of them will be rewritten as\n    ``table.column``.  This can be avoided by using the SQL ``AS``\n    keyword. (This is yet-another reason not to use ``*`` in SQL\n    queries, particularly where ``JOIN`` is involved.)\n\nCursor\n    The default cursor class. This class is composed of\n    ``CursorWarningMixIn``, ``CursorStoreResultMixIn``,\n    ``CursorTupleRowsMixIn,`` and ``BaseCursor``, i.e. it raises\n    ``Warning``, uses ``mysql_store_result()``, and returns rows as\n    tuples.\n\nDictCursor\n    Like ``Cursor`` except it returns rows as dictionaries.\n\nSSCursor\n    A \"server-side\" cursor. Like ``Cursor`` but uses\n    ``CursorUseResultMixIn``.  Use only if you are dealing with\n    potentially large result sets.\n\nSSDictCursor\n    Like ``SSCursor`` except it returns rows as dictionaries.\n\n\nEmbedded Server\n---------------\n\nInstead of connecting to a stand-alone server over the network,\nthe embedded server support lets you run a full server right in\nyour Python code or application server.\n\nIf you have built MySQLdb with embedded server support, there\nare two additional functions you will need to make use of:\n\n  server_init(args, groups)\n    Initialize embedded server. If this client is not linked against\n    the embedded server library, this function does nothing.\n\n    args\n\tsequence of command-line arguments\n    groups\n\tsequence of groups to use in defaults files\n\n  server_end()\n    Shut down embedded server. If not using an embedded server, this\n    does nothing.\n\nSee the MySQL documentation for more information on the embedded\nserver.\n\n\n\n:Title: MySQLdb: a Python interface for MySQL\n:Author: Andy Dustman\n:Version: $Revision$\n"
  },
  {
    "path": "metadata.cfg",
    "content": "[metadata]\nversion: 1.2.4\nversion_info: (1,2,4,'final',1)\ndescription: Python interface to MySQL\nlong_description: \n        =========================\n        Python interface to MySQL\n        =========================\n        \\n\n        MySQLdb is an interface to the popular MySQL_ database server for\n        Python.  The design goals are:\n        \\n\n        - Compliance with Python database API version 2.0 [PEP-0249]_\n        - Thread-safety\n        - Thread-friendliness (threads will not block each other) \n        \\n\n        MySQL-3.23 through 5.5 and Python-2.4 through 2.7 are currently\n        supported. Python-3.0 will be supported in a future release.\n        PyPy is supported.\n        \\n\n        MySQLdb is `Free Software`_.\n        \\n\n        .. _MySQL: http://www.mysql.com/\n        .. _`Free Software`: http://www.gnu.org/\n        .. [PEP-0249] http://www.python.org/peps/pep-0249.html\nauthor: Andy Dustman\nauthor_email: farcepest@gmail.com\nlicense: GPL\nplatforms: ALL\nurl: https://github.com/farcepest/MySQLdb1\nclassifiers:\n        Development Status :: 5 - Production/Stable\n        Environment :: Other Environment\n        License :: OSI Approved :: GNU General Public License (GPL)\n        Operating System :: MacOS :: MacOS X\n        Operating System :: Microsoft :: Windows :: Windows NT/2000\n        Operating System :: OS Independent\n        Operating System :: POSIX\n        Operating System :: POSIX :: Linux\n        Operating System :: Unix\n        Programming Language :: C\n        Programming Language :: Python\n        Topic :: Database\n        Topic :: Database :: Database Engines/Servers\npy_modules:\n        _mysql_exceptions\n        MySQLdb.converters\n        MySQLdb.connections\n        MySQLdb.cursors\n        MySQLdb.release\n        MySQLdb.times\n        MySQLdb.constants.CR\n        MySQLdb.constants.FIELD_TYPE\n        MySQLdb.constants.ER\n        MySQLdb.constants.FLAG\n        MySQLdb.constants.REFRESH\n        MySQLdb.constants.CLIENT\n\n"
  },
  {
    "path": "pymemcompat.h",
    "content": "\n/* The idea of this file is that you bundle it with your extension,\n   #include it, program to Python 2.3's memory API and have your\n   extension build with any version of Python from 1.5.2 through to\n   2.3 (and hopefully beyond). */\n\n#ifndef Py_PYMEMCOMPAT_H\n#define Py_PYMEMCOMPAT_H\n\n#include \"Python.h\"\n\n/* There are three \"families\" of memory API: the \"raw memory\", \"object\n   memory\" and \"object\" families.  (This is ignoring the matter of the\n   cycle collector, about which more is said below).\n\n   Raw Memory:\n\n       PyMem_Malloc, PyMem_Realloc, PyMem_Free\n\n   Object Memory:\n\n       PyObject_Malloc, PyObject_Realloc, PyObject_Free\n\n   Object:\n\n       PyObject_New, PyObject_NewVar, PyObject_Del\n\n   The raw memory and object memory allocators both mimic the\n   malloc/realloc/free interface from ANSI C, but the object memory\n   allocator can (and, since 2.3, does by default) use a different\n   allocation strategy biased towards lots of lots of \"small\"\n   allocations.\n\n   The object family is used for allocating Python objects, and the\n   initializers take care of some basic initialization (setting the\n   refcount to 1 and filling out the ob_type field) as well as having\n   a somewhat different interface.\n\n   Do not mix the families!  E.g. do not allocate memory with\n   PyMem_Malloc and free it with PyObject_Free.  You may get away with\n   it quite a lot of the time, but there *are* scenarios where this\n   will break.  You Have Been Warned. \n\n   Also, in many versions of Python there are an insane amount of\n   memory interfaces to choose from.  Use the ones described above. */\n\n#if PY_VERSION_HEX < 0x01060000\n/* raw memory interface already present */\n\n/* there is no object memory interface in 1.5.2 */\n#define PyObject_Malloc         PyMem_Malloc\n#define PyObject_Realloc        PyMem_Realloc\n#define PyObject_Free           PyMem_Free\n\n/* the object interface is there, but the names have changed */\n#define PyObject_New            PyObject_NEW\n#define PyObject_NewVar         PyObject_NEW_VAR\n#define PyObject_Del            PyMem_Free\n#endif\n\n/* If your object is a container you probably want to support the\n   cycle collector, which was new in Python 2.0.\n\n   Unfortunately, the interface to the collector that was present in\n   Python 2.0 and 2.1 proved to be tricky to use, and so changed in\n   2.2 -- in a way that can't easily be papered over with macros.\n\n   This file contains macros that let you program to the 2.2 GC API.\n   Your module will compile against any Python since version 1.5.2,\n   but the type will only participate in the GC in versions 2.2 and\n   up.  Some work is still necessary on your part to only fill out the\n   tp_traverse and tp_clear fields when they exist and set tp_flags\n   appropriately.\n\n   It is possible to support both the 2.0 and 2.2 GC APIs, but it's\n   not pretty and this comment block is too narrow to contain a\n   desciption of what's required... */\n\n#if PY_VERSION_HEX < 0x020200B1\n#define PyObject_GC_New         PyObject_New\n#define PyObject_GC_NewVar      PyObject_NewVar\n#define PyObject_GC_Del         PyObject_Del\n#define PyObject_GC_Track(op)\n#define PyObject_GC_UnTrack(op)\n#endif\n\n#endif /* !Py_PYMEMCOMPAT_H */\n"
  },
  {
    "path": "setup.cfg",
    "content": "[test]\ntest_suite = nose.collector\n\n[build_ext]\n## Only uncomment/set these if the default configuration doesn't work\n## Also see http://docs.python.org/dist/setup-config.html\n# include-dirs = ?\n# library-dirs = ?\n# link-objects = ?\n# rpath = ?\n# libraries = ?\n\n[bdist_rpm]\ndoc_files = README MANIFEST doc/*.txt\nvendor = MySQL-python SourceForge Project\npackager = Andy Dustman <adustman@users.sourceforge.net>\ndistribution-name = Red Stains Linux\nrequires = python\nbuild-requires = python-devel mysql-devel zlib-devel openssl-devel\n"
  },
  {
    "path": "setup.py",
    "content": "#!/usr/bin/env python\n\nimport os\nimport sys\n\nimport distutils.errors\nimport setuptools\n\nif not hasattr(sys, \"hexversion\") or sys.hexversion < 0x02040000:\n    raise distutils.errors.DistutilsError(\"Python 2.4 or newer is required\")\n\nif os.name == \"posix\":\n    from setup_posix import get_config\nelse:  # assume windows\n    from setup_windows import get_config\n\nmetadata, options = get_config()\nmetadata['ext_modules'] = [\n    setuptools.Extension(sources=['_mysql.c'], **options)]\nmetadata['long_description'] = metadata['long_description'].replace(r'\\n', '')\nsetuptools.setup(**metadata)\n"
  },
  {
    "path": "setup_common.py",
    "content": "try:\n    # Python 2.x\n    from ConfigParser import SafeConfigParser\nexcept ImportError:\n    # Python 3.x\n    from configparser import ConfigParser as SafeConfigParser\n\ndef get_metadata_and_options():\n    config = SafeConfigParser()\n    config.read(['metadata.cfg', 'site.cfg'])\n\n    metadata = dict(config.items('metadata'))\n    options = dict(config.items('options'))\n\n    metadata['py_modules'] = list(filter(None, metadata['py_modules'].split('\\n')))\n    metadata['classifiers'] = list(filter(None, metadata['classifiers'].split('\\n')))\n\n    return metadata, options\n\ndef enabled(options, option):\n    value = options[option]\n    s = value.lower()\n    if s in ('yes','true','1','y'):\n        return True\n    elif s in ('no', 'false', '0', 'n'):\n        return False\n    else:\n        raise ValueError(\"Unknown value %s for option %s\" % (value, option))\n\ndef create_release_file(metadata):\n    rel = open(\"MySQLdb/release.py\",'w')\n    rel.write(\"\"\"\n__author__ = \"%(author)s <%(author_email)s>\"\nversion_info = %(version_info)s\n__version__ = \"%(version)s\"\n\"\"\" % metadata)\n    rel.close()\n"
  },
  {
    "path": "setup_posix.py",
    "content": "import os, sys\nfrom ConfigParser import SafeConfigParser\n\n# This dequote() business is required for some older versions\n# of mysql_config\n\ndef dequote(s):\n    if s[0] in \"\\\"'\" and s[0] == s[-1]:\n        s = s[1:-1]\n    return s\n\ndef compiler_flag(f):\n    return \"-%s\" % f\n\ndef mysql_config(what):\n    from os import popen\n\n    f = popen(\"%s --%s\" % (mysql_config.path, what))\n    data = f.read().strip().split()\n    ret = f.close()\n    if ret:\n        if ret/256:\n            data = []\n        if ret/256 > 1:\n            raise EnvironmentError(\"%s not found\" % (mysql_config.path,))\n    return data\nmysql_config.path = \"mysql_config\"\n\ndef get_config():\n    from setup_common import get_metadata_and_options, enabled, create_release_file\n\n    metadata, options = get_metadata_and_options()\n\n    if 'mysql_config' in options:\n        mysql_config.path = options['mysql_config']\n\n    extra_objects = []\n    static = enabled(options, 'static')\n    if enabled(options, 'embedded'):\n        libs = mysql_config(\"libmysqld-libs\")\n        client = \"mysqld\"\n    elif enabled(options, 'threadsafe'):\n        libs = mysql_config(\"libs_r\")\n        client = \"mysqlclient_r\"\n        if not libs:\n            libs = mysql_config(\"libs\")\n            client = \"mysqlclient\"\n    else:\n        libs = mysql_config(\"libs\")\n        client = \"mysqlclient\"\n\n    library_dirs = [ dequote(i[2:]) for i in libs if i.startswith(compiler_flag(\"L\")) ]\n    libraries = [ dequote(i[2:]) for i in libs if i.startswith(compiler_flag(\"l\")) ]\n\n    removable_compile_args = [ compiler_flag(f) for f in \"ILl\" ]\n    extra_compile_args = [ i.replace(\"%\", \"%%\") for i in mysql_config(\"cflags\")\n                           if i[:2] not in removable_compile_args ]\n\n    # Copy the arch flags for linking as well\n    extra_link_args = list()\n    for i in range(len(extra_compile_args)):\n        if extra_compile_args[i] == '-arch':\n            extra_link_args += ['-arch', extra_compile_args[i + 1]]\n\n    include_dirs = [ dequote(i[2:])\n                     for i in mysql_config('include')\n                     if i.startswith(compiler_flag('I')) ]\n    if not include_dirs: # fix for MySQL-3.23\n        include_dirs = [ dequote(i[2:])\n                         for i in mysql_config('cflags')\n                         if i.startswith(compiler_flag('I')) ]\n\n    if static:\n        extra_objects.append(os.path.join(library_dirs[0],'lib%s.a' % client))\n        if client in libraries:\n            libraries.remove(client)\n\n    name = \"MySQL-python\"\n    if enabled(options, 'embedded'):\n        name = name + \"-embedded\"\n    metadata['name'] = name\n\n    define_macros = [\n        ('version_info', metadata['version_info']),\n        ('__version__', metadata['version']),\n        ]\n    create_release_file(metadata)\n    del metadata['version_info']\n    ext_options = dict(\n        name = \"_mysql\",\n        library_dirs = library_dirs,\n        libraries = libraries,\n        extra_compile_args = extra_compile_args,\n        extra_link_args = extra_link_args,\n        include_dirs = include_dirs,\n        extra_objects = extra_objects,\n        define_macros = define_macros,\n        )\n    return metadata, ext_options\n\nif __name__ == \"__main__\":\n    sys.stderr.write(\"\"\"You shouldn't be running this directly; it is used by setup.py.\"\"\")\n\n"
  },
  {
    "path": "setup_windows.py",
    "content": "import os, sys\n\ndef get_config():\n    from setup_common import get_metadata_and_options, enabled, create_release_file\n\n    metadata, options = get_metadata_and_options()\n\n    connector = options[\"connector\"]\n\n    extra_objects = []\n\n    if enabled(options, 'embedded'):\n        client = \"mysqld\"\n    else:\n        client = \"mysqlclient\"\n\n    library_dirs = [ os.path.join(connector, r'lib\\opt') ]\n    libraries = [ 'kernel32', 'advapi32', 'wsock32', client ]\n    include_dirs = [ os.path.join(connector, r'include') ]\n    extra_compile_args = [ '/Zl' ]\n    \n    name = \"MySQL-python\"\n    if enabled(options, 'embedded'):\n        name = name + \"-embedded\"\n    metadata['name'] = name\n    \n    define_macros = [\n        ('version_info', metadata['version_info']),\n        ('__version__', metadata['version']),\n        ]\n    create_release_file(metadata)\n    del metadata['version_info']\n    ext_options = dict(\n        name = \"_mysql\",\n        library_dirs = library_dirs,\n        libraries = libraries,\n        extra_compile_args = extra_compile_args,\n        include_dirs = include_dirs,\n        extra_objects = extra_objects,\n        define_macros = define_macros,\n        )\n    return metadata, ext_options\n\nif __name__ == \"__main__\":\n    sys.stderr.write(\"\"\"You shouldn't be running this directly; it is used by setup.py.\"\"\")\n    \n"
  },
  {
    "path": "site.cfg",
    "content": "[options]\n# embedded: link against the embedded server library\n# threadsafe: use the threadsafe client\n# static: link against a static library (probably required for embedded)\n\nembedded = False\nthreadsafe = True\nstatic = False\n\n# The path to mysql_config.\n# Only use this if mysql_config is not on your PATH, or you have some weird\n# setup that requires it.\n#mysql_config = /usr/local/bin/mysql_config\n\n# http://stackoverflow.com/questions/1972259/mysql-python-install-problem-using-virtualenv-windows-pip\n# Windows connector libs for MySQL. You need a 32-bit connector for your 32-bit Python build.\nconnector = C:\\Program Files (x86)\\MySQL\\MySQL Connector C 6.0.2\n"
  },
  {
    "path": "tests/capabilities.py",
    "content": "#!/usr/bin/env python -O\r\n\"\"\" Script to test database capabilities and the DB-API interface\r\n    for functionality and memory leaks.\r\n\r\n    Adapted from a script by M-A Lemburg.\r\n    \r\n\"\"\"\r\nfrom time import time\r\nimport array\r\nimport unittest\r\nfrom configdb import connection_factory\r\n\r\n\r\nclass DatabaseTest(unittest.TestCase):\r\n\r\n    db_module = None\r\n    connect_args = ()\r\n    connect_kwargs = dict()\r\n    create_table_extra = ''\r\n    rows = 10\r\n    debug = False\r\n    \r\n    def setUp(self):\r\n        import gc\r\n        db = connection_factory(**self.connect_kwargs)\r\n        self.connection = db\r\n        self.cursor = db.cursor()\r\n        # TODO: this needs to be re-evaluated for Python 3\r\n        self.BLOBText = ''.join([chr(i) for i in range(256)] * 100);\r\n        self.BLOBUText = u''.join([unichr(i) for i in range(16384)])\r\n        self.BLOBBinary = self.db_module.Binary(''.join([chr(i) for i in range(256)] * 16))\r\n\r\n    leak_test = True\r\n    \r\n    def tearDown(self):\r\n        if self.leak_test:\r\n            import gc\r\n            del self.cursor\r\n            orphans = gc.collect()\r\n            self.failIf(orphans, \"%d orphaned objects found after deleting cursor\" % orphans)\r\n            \r\n            del self.connection\r\n            orphans = gc.collect()\r\n            self.failIf(orphans, \"%d orphaned objects found after deleting connection\" % orphans)\r\n            \r\n    def table_exists(self, name):\r\n        try:\r\n            self.cursor.execute('select * from %s where 1=0' % name)\r\n        except:\r\n            return False\r\n        else:\r\n            return True\r\n\r\n    def quote_identifier(self, ident):\r\n        return '\"%s\"' % ident\r\n    \r\n    def new_table_name(self):\r\n        i = id(self.cursor)\r\n        while True:\r\n            name = self.quote_identifier('tb%08x' % i)\r\n            if not self.table_exists(name):\r\n                return name\r\n            i = i + 1\r\n\r\n    def create_table(self, columndefs):\r\n\r\n        \"\"\" Create a table using a list of column definitions given in\r\n            columndefs.\r\n        \r\n            generator must be a function taking arguments (row_number,\r\n            col_number) returning a suitable data object for insertion\r\n            into the table.\r\n\r\n        \"\"\"\r\n        self.table = self.new_table_name()\r\n        self.cursor.execute('CREATE TABLE %s (%s) %s' % \r\n                            (self.table,\r\n                             ',\\n'.join(columndefs),\r\n                             self.create_table_extra))\r\n\r\n    def check_data_integrity(self, columndefs, generator):\r\n        # insert\r\n        self.create_table(columndefs)\r\n        insert_statement = ('INSERT INTO %s VALUES (%s)' % \r\n                            (self.table,\r\n                             ','.join(['%s'] * len(columndefs))))\r\n        data = [ [ generator(i,j) for j in range(len(columndefs)) ]\r\n                 for i in range(self.rows) ]\r\n        self.cursor.executemany(insert_statement, data)\r\n        self.connection.commit()\r\n        # verify\r\n        self.cursor.execute('select * from %s' % self.table)\r\n        l = self.cursor.fetchall()\r\n        self.assertEquals(len(l), self.rows)\r\n        try:\r\n            for i in range(self.rows):\r\n                for j in range(len(columndefs)):\r\n                    self.assertEquals(l[i][j], generator(i,j))\r\n        finally:\r\n            if not self.debug:\r\n                self.cursor.execute('drop table %s' % (self.table))\r\n\r\n    def test_transactions(self):\r\n        columndefs = ( 'col1 INT', 'col2 VARCHAR(255)')\r\n        def generator(row, col):\r\n            if col == 0: return row\r\n            else: return ('%i' % (row%10))*255\r\n        self.create_table(columndefs)\r\n        insert_statement = ('INSERT INTO %s VALUES (%s)' % \r\n                            (self.table,\r\n                             ','.join(['%s'] * len(columndefs))))\r\n        data = [ [ generator(i,j) for j in range(len(columndefs)) ]\r\n                 for i in range(self.rows) ]\r\n        self.cursor.executemany(insert_statement, data)\r\n        # verify\r\n        self.connection.commit()\r\n        self.cursor.execute('select * from %s' % self.table)\r\n        l = self.cursor.fetchall()\r\n        self.assertEquals(len(l), self.rows)\r\n        for i in range(self.rows):\r\n            for j in range(len(columndefs)):\r\n                self.assertEquals(l[i][j], generator(i,j))\r\n        delete_statement = 'delete from %s where col1=%%s' % self.table\r\n        self.cursor.execute(delete_statement, (0,))\r\n        self.cursor.execute('select col1 from %s where col1=%s' % \\\r\n                            (self.table, 0))\r\n        l = self.cursor.fetchall()\r\n        self.assertFalse(l, \"DELETE didn't work\")\r\n        self.connection.rollback()\r\n        self.cursor.execute('select col1 from %s where col1=%s' % \\\r\n                            (self.table, 0))\r\n        l = self.cursor.fetchall()\r\n        self.assertTrue(len(l) == 1, \"ROLLBACK didn't work\")\r\n        self.cursor.execute('drop table %s' % (self.table))\r\n\r\n    def test_truncation(self):\r\n        columndefs = ( 'col1 INT', 'col2 VARCHAR(255)')\r\n        def generator(row, col):\r\n            if col == 0: return row\r\n            else: return ('%i' % (row%10))*((255-self.rows/2)+row)\r\n        self.create_table(columndefs)\r\n        insert_statement = ('INSERT INTO %s VALUES (%s)' % \r\n                            (self.table,\r\n                             ','.join(['%s'] * len(columndefs))))\r\n\r\n        try:\r\n            self.cursor.execute(insert_statement, (0, '0'*256))\r\n        except self.connection.DataError:\r\n            pass\r\n        else:\r\n            self.fail(\"Over-long column did not generate warnings/exception with single insert\")\r\n\r\n        self.connection.rollback()\r\n        \r\n        try:\r\n            for i in range(self.rows):\r\n                data = []\r\n                for j in range(len(columndefs)):\r\n                    data.append(generator(i,j))\r\n                self.cursor.execute(insert_statement,tuple(data))\r\n        except self.connection.DataError:\r\n            pass\r\n        else:\r\n            self.fail(\"Over-long columns did not generate warnings/exception with execute()\")\r\n\r\n        self.connection.rollback()\r\n        \r\n        try:\r\n            data = [ [ generator(i,j) for j in range(len(columndefs)) ]\r\n                     for i in range(self.rows) ]\r\n            self.cursor.executemany(insert_statement, data)\r\n        except self.connection.DataError:\r\n            pass\r\n        else:\r\n            self.fail(\"Over-long columns did not generate warnings/exception with executemany()\")\r\n\r\n        self.connection.rollback()\r\n        self.cursor.execute('drop table %s' % (self.table))\r\n\r\n    def test_CHAR(self):\r\n        # Character data\r\n        def generator(row,col):\r\n            return ('%i' % ((row+col) % 10)) * 255\r\n        self.check_data_integrity(\r\n            ('col1 char(255)','col2 char(255)'),\r\n            generator)\r\n\r\n    def test_INT(self):\r\n        # Number data\r\n        def generator(row,col):\r\n            return row*row\r\n        self.check_data_integrity(\r\n            ('col1 INT',),\r\n            generator)\r\n\r\n    def test_DECIMAL(self):\r\n        # DECIMAL\r\n        def generator(row,col):\r\n            from decimal import Decimal\r\n            return Decimal(\"%d.%02d\" % (row, col))\r\n        self.check_data_integrity(\r\n            ('col1 DECIMAL(5,2)',),\r\n            generator)\r\n\r\n    def test_DATE(self):\r\n        ticks = time()\r\n        def generator(row,col):\r\n            return self.db_module.DateFromTicks(ticks+row*86400-col*1313)\r\n        self.check_data_integrity(\r\n                 ('col1 DATE',),\r\n                 generator)\r\n\r\n    def test_TIME(self):\r\n        ticks = time()\r\n        def generator(row,col):\r\n            return self.db_module.TimeFromTicks(ticks+row*86400-col*1313)\r\n        self.check_data_integrity(\r\n                 ('col1 TIME',),\r\n                 generator)\r\n\r\n    def test_DATETIME(self):\r\n        ticks = time()\r\n        def generator(row,col):\r\n            return self.db_module.TimestampFromTicks(ticks+row*86400-col*1313)\r\n        self.check_data_integrity(\r\n                 ('col1 DATETIME',),\r\n                 generator)\r\n\r\n    def test_TIMESTAMP(self):\r\n        ticks = time()\r\n        def generator(row,col):\r\n            return self.db_module.TimestampFromTicks(ticks+row*86400-col*1313)\r\n        self.check_data_integrity(\r\n                 ('col1 TIMESTAMP',),\r\n                 generator)\r\n\r\n    def test_fractional_TIMESTAMP(self):\r\n        ticks = time()\r\n        def generator(row,col):\r\n            return self.db_module.TimestampFromTicks(ticks+row*86400-col*1313+row*0.7*col/3.0)\r\n        self.check_data_integrity(\r\n                 ('col1 TIMESTAMP',),\r\n                 generator)\r\n\r\n    def test_LONG(self):\r\n        def generator(row,col):\r\n            if col == 0:\r\n                return row\r\n            else:\r\n                return self.BLOBUText # 'BLOB Text ' * 1024\r\n        self.check_data_integrity(\r\n                 ('col1 INT','col2 LONG'),\r\n                 generator)\r\n\r\n    def test_TEXT(self):\r\n        def generator(row,col):\r\n            return self.BLOBUText # 'BLOB Text ' * 1024\r\n        self.check_data_integrity(\r\n                 ('col2 TEXT',),\r\n                 generator)\r\n\r\n    def test_LONG_BYTE(self):\r\n        def generator(row,col):\r\n            if col == 0:\r\n                return row\r\n            else:\r\n                return self.BLOBBinary # 'BLOB\\000Binary ' * 1024\r\n        self.check_data_integrity(\r\n                 ('col1 INT','col2 LONG BYTE'),\r\n                 generator)\r\n\r\n    def test_BLOB(self):\r\n        def generator(row,col):\r\n            if col == 0:\r\n                return row\r\n            else:\r\n                return self.BLOBBinary # 'BLOB\\000Binary ' * 1024\r\n        self.check_data_integrity(\r\n                 ('col1 INT','col2 BLOB'),\r\n                 generator)\r\n\r\n"
  },
  {
    "path": "tests/configdb.py",
    "content": "\"\"\"Configure database connection for tests.\"\"\"\n\nfrom os import environ, path\n\ntests_path = path.dirname(__file__)\nconf_file = environ.get('TESTDB', 'default.cnf')\nconf_path = path.join(tests_path, conf_file)\nconnect_kwargs = dict(\n    read_default_file = conf_path,\n    read_default_group = \"MySQLdb-tests\",\n)\n\ndef connection_kwargs(kwargs):\n    db_kwargs = connect_kwargs.copy()\n    db_kwargs.update(kwargs)\n    return db_kwargs\n\ndef connection_factory(**kwargs):\n    import MySQLdb\n    db_kwargs = connection_kwargs(kwargs)\n    db = MySQLdb.connect(**db_kwargs)\n    return db\n\n\n\n"
  },
  {
    "path": "tests/dbapi20.py",
    "content": "#!/usr/bin/env python\n''' Python DB API 2.0 driver compliance unit test suite. \n    \n    This software is Public Domain and may be used without restrictions.\n\n \"Now we have booze and barflies entering the discussion, plus rumours of\n  DBAs on drugs... and I won't tell you what flashes through my mind each\n  time I read the subject line with 'Anal Compliance' in it.  All around\n  this is turning out to be a thoroughly unwholesome unit test.\"\n\n    -- Ian Bicking\n'''\n\n__rcs_id__  = '$Id$'\n__version__ = '$Revision$'[11:-2]\n__author__ = 'Stuart Bishop <zen@shangri-la.dropbear.id.au>'\n\nimport unittest\nimport time\n\n# $Log$\n# Revision 1.1.2.1  2006/02/25 03:44:32  adustman\n# Generic DB-API unit test module\n#\n# Revision 1.10  2003/10/09 03:14:14  zenzen\n# Add test for DB API 2.0 optional extension, where database exceptions\n# are exposed as attributes on the Connection object.\n#\n# Revision 1.9  2003/08/13 01:16:36  zenzen\n# Minor tweak from Stefan Fleiter\n#\n# Revision 1.8  2003/04/10 00:13:25  zenzen\n# Changes, as per suggestions by M.-A. Lemburg\n# - Add a table prefix, to ensure namespace collisions can always be avoided\n#\n# Revision 1.7  2003/02/26 23:33:37  zenzen\n# Break out DDL into helper functions, as per request by David Rushby\n#\n# Revision 1.6  2003/02/21 03:04:33  zenzen\n# Stuff from Henrik Ekelund:\n#     added test_None\n#     added test_nextset & hooks\n#\n# Revision 1.5  2003/02/17 22:08:43  zenzen\n# Implement suggestions and code from Henrik Eklund - test that cursor.arraysize\n# defaults to 1 & generic cursor.callproc test added\n#\n# Revision 1.4  2003/02/15 00:16:33  zenzen\n# Changes, as per suggestions and bug reports by M.-A. Lemburg,\n# Matthew T. Kromer, Federico Di Gregorio and Daniel Dittmar\n# - Class renamed\n# - Now a subclass of TestCase, to avoid requiring the driver stub\n#   to use multiple inheritance\n# - Reversed the polarity of buggy test in test_description\n# - Test exception heirarchy correctly\n# - self.populate is now self._populate(), so if a driver stub\n#   overrides self.ddl1 this change propogates\n# - VARCHAR columns now have a width, which will hopefully make the\n#   DDL even more portible (this will be reversed if it causes more problems)\n# - cursor.rowcount being checked after various execute and fetchXXX methods\n# - Check for fetchall and fetchmany returning empty lists after results\n#   are exhausted (already checking for empty lists if select retrieved\n#   nothing\n# - Fix bugs in test_setoutputsize_basic and test_setinputsizes\n#\n\nclass DatabaseAPI20Test(unittest.TestCase):\n    ''' Test a database self.driver for DB API 2.0 compatibility.\n        This implementation tests Gadfly, but the TestCase\n        is structured so that other self.drivers can subclass this \n        test case to ensure compiliance with the DB-API. It is \n        expected that this TestCase may be expanded in the future\n        if ambiguities or edge conditions are discovered.\n\n        The 'Optional Extensions' are not yet being tested.\n\n        self.drivers should subclass this test, overriding setUp, tearDown,\n        self.driver, connect_args and connect_kw_args. Class specification\n        should be as follows:\n\n        import dbapi20 \n        class mytest(dbapi20.DatabaseAPI20Test):\n           [...] \n\n        Don't 'import DatabaseAPI20Test from dbapi20', or you will\n        confuse the unit tester - just 'import dbapi20'.\n    '''\n\n    # The self.driver module. This should be the module where the 'connect'\n    # method is to be found\n    driver = None\n    connect_args = () # List of arguments to pass to connect\n    connect_kw_args = {} # Keyword arguments for connect\n    table_prefix = 'dbapi20test_' # If you need to specify a prefix for tables\n\n    ddl1 = 'create table %sbooze (name varchar(20))' % table_prefix\n    ddl2 = 'create table %sbarflys (name varchar(20))' % table_prefix\n    xddl1 = 'drop table %sbooze' % table_prefix\n    xddl2 = 'drop table %sbarflys' % table_prefix\n\n    lowerfunc = 'lower' # Name of stored procedure to convert string->lowercase\n        \n    # Some drivers may need to override these helpers, for example adding\n    # a 'commit' after the execute.\n    def executeDDL1(self,cursor):\n        cursor.execute(self.ddl1)\n\n    def executeDDL2(self,cursor):\n        cursor.execute(self.ddl2)\n\n    def setUp(self):\n        ''' self.drivers should override this method to perform required setup\n            if any is necessary, such as creating the database.\n        '''\n        pass\n\n    def tearDown(self):\n        ''' self.drivers should override this method to perform required cleanup\n            if any is necessary, such as deleting the test database.\n            The default drops the tables that may be created.\n        '''\n        con = self._connect()\n        try:\n            cur = con.cursor()\n            for ddl in (self.xddl1,self.xddl2):\n                try: \n                    cur.execute(ddl)\n                    con.commit()\n                except self.driver.Error: \n                    # Assume table didn't exist. Other tests will check if\n                    # execute is busted.\n                    pass\n        finally:\n            con.close()\n\n    def _connect(self):\n        try:\n            return self.driver.connect(\n                *self.connect_args,**self.connect_kw_args\n                )\n        except AttributeError:\n            self.fail(\"No connect method found in self.driver module\")\n\n    def test_connect(self):\n        con = self._connect()\n        con.close()\n\n    def test_apilevel(self):\n        try:\n            # Must exist\n            apilevel = self.driver.apilevel\n            # Must equal 2.0\n            self.assertEqual(apilevel,'2.0')\n        except AttributeError:\n            self.fail(\"Driver doesn't define apilevel\")\n\n    def test_threadsafety(self):\n        try:\n            # Must exist\n            threadsafety = self.driver.threadsafety\n            # Must be a valid value\n            self.assertTrue(threadsafety in (0,1,2,3))\n        except AttributeError:\n            self.fail(\"Driver doesn't define threadsafety\")\n\n    def test_paramstyle(self):\n        try:\n            # Must exist\n            paramstyle = self.driver.paramstyle\n            # Must be a valid value\n            self.assertTrue(paramstyle in (\n                'qmark','numeric','named','format','pyformat'\n                ))\n        except AttributeError:\n            self.fail(\"Driver doesn't define paramstyle\")\n\n    def test_Exceptions(self):\n        # Make sure required exceptions exist, and are in the\n        # defined heirarchy.\n        self.assertTrue(issubclass(self.driver.Warning,StandardError))\n        self.assertTrue(issubclass(self.driver.Error,StandardError))\n        self.assertTrue(\n            issubclass(self.driver.InterfaceError,self.driver.Error)\n            )\n        self.assertTrue(\n            issubclass(self.driver.DatabaseError,self.driver.Error)\n            )\n        self.assertTrue(\n            issubclass(self.driver.OperationalError,self.driver.Error)\n            )\n        self.assertTrue(\n            issubclass(self.driver.IntegrityError,self.driver.Error)\n            )\n        self.assertTrue(\n            issubclass(self.driver.InternalError,self.driver.Error)\n            )\n        self.assertTrue(\n            issubclass(self.driver.ProgrammingError,self.driver.Error)\n            )\n        self.assertTrue(\n            issubclass(self.driver.NotSupportedError,self.driver.Error)\n            )\n\n    def test_ExceptionsAsConnectionAttributes(self):\n        # OPTIONAL EXTENSION\n        # Test for the optional DB API 2.0 extension, where the exceptions\n        # are exposed as attributes on the Connection object\n        # I figure this optional extension will be implemented by any\n        # driver author who is using this test suite, so it is enabled\n        # by default.\n        con = self._connect()\n        drv = self.driver\n        self.assertTrue(con.Warning is drv.Warning)\n        self.assertTrue(con.Error is drv.Error)\n        self.assertTrue(con.InterfaceError is drv.InterfaceError)\n        self.assertTrue(con.DatabaseError is drv.DatabaseError)\n        self.assertTrue(con.OperationalError is drv.OperationalError)\n        self.assertTrue(con.IntegrityError is drv.IntegrityError)\n        self.assertTrue(con.InternalError is drv.InternalError)\n        self.assertTrue(con.ProgrammingError is drv.ProgrammingError)\n        self.assertTrue(con.NotSupportedError is drv.NotSupportedError)\n\n\n    def test_commit(self):\n        con = self._connect()\n        try:\n            # Commit must work, even if it doesn't do anything\n            con.commit()\n        finally:\n            con.close()\n\n    def test_rollback(self):\n        con = self._connect()\n        # If rollback is defined, it should either work or throw\n        # the documented exception\n        if hasattr(con,'rollback'):\n            try:\n                con.rollback()\n            except self.driver.NotSupportedError:\n                pass\n    \n    def test_cursor(self):\n        con = self._connect()\n        try:\n            cur = con.cursor()\n        finally:\n            con.close()\n\n    def test_cursor_isolation(self):\n        con = self._connect()\n        try:\n            # Make sure cursors created from the same connection have\n            # the documented transaction isolation level\n            cur1 = con.cursor()\n            cur2 = con.cursor()\n            self.executeDDL1(cur1)\n            cur1.execute(\"insert into %sbooze values ('Victoria Bitter')\" % (\n                self.table_prefix\n                ))\n            cur2.execute(\"select name from %sbooze\" % self.table_prefix)\n            booze = cur2.fetchall()\n            self.assertEqual(len(booze),1)\n            self.assertEqual(len(booze[0]),1)\n            self.assertEqual(booze[0][0],'Victoria Bitter')\n        finally:\n            con.close()\n\n    def test_description(self):\n        con = self._connect()\n        try:\n            cur = con.cursor()\n            self.executeDDL1(cur)\n            self.assertEqual(cur.description,None,\n                'cursor.description should be none after executing a '\n                'statement that can return no rows (such as DDL)'\n                )\n            cur.execute('select name from %sbooze' % self.table_prefix)\n            self.assertEqual(len(cur.description),1,\n                'cursor.description describes too many columns'\n                )\n            self.assertEqual(len(cur.description[0]),7,\n                'cursor.description[x] tuples must have 7 elements'\n                )\n            self.assertEqual(cur.description[0][0].lower(),'name',\n                'cursor.description[x][0] must return column name'\n                )\n            self.assertEqual(cur.description[0][1],self.driver.STRING,\n                'cursor.description[x][1] must return column type. Got %r'\n                    % cur.description[0][1]\n                )\n\n            # Make sure self.description gets reset\n            self.executeDDL2(cur)\n            self.assertEqual(cur.description,None,\n                'cursor.description not being set to None when executing '\n                'no-result statements (eg. DDL)'\n                )\n        finally:\n            con.close()\n\n    def test_rowcount(self):\n        con = self._connect()\n        try:\n            cur = con.cursor()\n            self.executeDDL1(cur)\n            self.assertEqual(cur.rowcount,-1,\n                'cursor.rowcount should be -1 after executing no-result '\n                'statements'\n                )\n            cur.execute(\"insert into %sbooze values ('Victoria Bitter')\" % (\n                self.table_prefix\n                ))\n            self.assertTrue(cur.rowcount in (-1,1),\n                'cursor.rowcount should == number or rows inserted, or '\n                'set to -1 after executing an insert statement'\n                )\n            cur.execute(\"select name from %sbooze\" % self.table_prefix)\n            self.assertTrue(cur.rowcount in (-1,1),\n                'cursor.rowcount should == number of rows returned, or '\n                'set to -1 after executing a select statement'\n                )\n            self.executeDDL2(cur)\n            self.assertEqual(cur.rowcount,-1,\n                'cursor.rowcount not being reset to -1 after executing '\n                'no-result statements'\n                )\n        finally:\n            con.close()\n\n    lower_func = 'lower'\n    def test_callproc(self):\n        con = self._connect()\n        try:\n            cur = con.cursor()\n            if self.lower_func and hasattr(cur,'callproc'):\n                r = cur.callproc(self.lower_func,('FOO',))\n                self.assertEqual(len(r),1)\n                self.assertEqual(r[0],'FOO')\n                r = cur.fetchall()\n                self.assertEqual(len(r),1,'callproc produced no result set')\n                self.assertEqual(len(r[0]),1,\n                    'callproc produced invalid result set'\n                    )\n                self.assertEqual(r[0][0],'foo',\n                    'callproc produced invalid results'\n                    )\n        finally:\n            con.close()\n\n    def test_close(self):\n        con = self._connect()\n        try:\n            cur = con.cursor()\n        finally:\n            con.close()\n\n        # cursor.execute should raise an Error if called after connection\n        # closed\n        self.assertRaises(self.driver.Error,self.executeDDL1,cur)\n\n        # connection.commit should raise an Error if called after connection'\n        # closed.'\n        self.assertRaises(self.driver.Error,con.commit)\n\n        # connection.close should raise an Error if called more than once\n        self.assertRaises(self.driver.Error,con.close)\n\n    def test_execute(self):\n        con = self._connect()\n        try:\n            cur = con.cursor()\n            self._paraminsert(cur)\n        finally:\n            con.close()\n\n    def _paraminsert(self,cur):\n        self.executeDDL1(cur)\n        cur.execute(\"insert into %sbooze values ('Victoria Bitter')\" % (\n            self.table_prefix\n            ))\n        self.assertTrue(cur.rowcount in (-1,1))\n\n        if self.driver.paramstyle == 'qmark':\n            cur.execute(\n                'insert into %sbooze values (?)' % self.table_prefix,\n                (\"Cooper's\",)\n                )\n        elif self.driver.paramstyle == 'numeric':\n            cur.execute(\n                'insert into %sbooze values (:1)' % self.table_prefix,\n                (\"Cooper's\",)\n                )\n        elif self.driver.paramstyle == 'named':\n            cur.execute(\n                'insert into %sbooze values (:beer)' % self.table_prefix, \n                {'beer':\"Cooper's\"}\n                )\n        elif self.driver.paramstyle == 'format':\n            cur.execute(\n                'insert into %sbooze values (%%s)' % self.table_prefix,\n                (\"Cooper's\",)\n                )\n        elif self.driver.paramstyle == 'pyformat':\n            cur.execute(\n                'insert into %sbooze values (%%(beer)s)' % self.table_prefix,\n                {'beer':\"Cooper's\"}\n                )\n        else:\n            self.fail('Invalid paramstyle')\n        self.assertTrue(cur.rowcount in (-1,1))\n\n        cur.execute('select name from %sbooze' % self.table_prefix)\n        res = cur.fetchall()\n        self.assertEqual(len(res),2,'cursor.fetchall returned too few rows')\n        beers = [res[0][0],res[1][0]]\n        beers.sort()\n        self.assertEqual(beers[0],\"Cooper's\",\n            'cursor.fetchall retrieved incorrect data, or data inserted '\n            'incorrectly'\n            )\n        self.assertEqual(beers[1],\"Victoria Bitter\",\n            'cursor.fetchall retrieved incorrect data, or data inserted '\n            'incorrectly'\n            )\n\n    def test_executemany(self):\n        con = self._connect()\n        try:\n            cur = con.cursor()\n            self.executeDDL1(cur)\n            largs = [ (\"Cooper's\",) , (\"Boag's\",) ]\n            margs = [ {'beer': \"Cooper's\"}, {'beer': \"Boag's\"} ]\n            if self.driver.paramstyle == 'qmark':\n                cur.executemany(\n                    'insert into %sbooze values (?)' % self.table_prefix,\n                    largs\n                    )\n            elif self.driver.paramstyle == 'numeric':\n                cur.executemany(\n                    'insert into %sbooze values (:1)' % self.table_prefix,\n                    largs\n                    )\n            elif self.driver.paramstyle == 'named':\n                cur.executemany(\n                    'insert into %sbooze values (:beer)' % self.table_prefix,\n                    margs\n                    )\n            elif self.driver.paramstyle == 'format':\n                cur.executemany(\n                    'insert into %sbooze values (%%s)' % self.table_prefix,\n                    largs\n                    )\n            elif self.driver.paramstyle == 'pyformat':\n                cur.executemany(\n                    'insert into %sbooze values (%%(beer)s)' % (\n                        self.table_prefix\n                        ),\n                    margs\n                    )\n            else:\n                self.fail('Unknown paramstyle')\n            self.assertTrue(cur.rowcount in (-1,2),\n                'insert using cursor.executemany set cursor.rowcount to '\n                'incorrect value %r' % cur.rowcount\n                )\n            cur.execute('select name from %sbooze' % self.table_prefix)\n            res = cur.fetchall()\n            self.assertEqual(len(res),2,\n                'cursor.fetchall retrieved incorrect number of rows'\n                )\n            beers = [res[0][0],res[1][0]]\n            beers.sort()\n            self.assertEqual(beers[0],\"Boag's\",'incorrect data retrieved')\n            self.assertEqual(beers[1],\"Cooper's\",'incorrect data retrieved')\n        finally:\n            con.close()\n\n    def test_fetchone(self):\n        con = self._connect()\n        try:\n            cur = con.cursor()\n\n            # cursor.fetchone should raise an Error if called before\n            # executing a select-type query\n            self.assertRaises(self.driver.Error,cur.fetchone)\n\n            # cursor.fetchone should raise an Error if called after\n            # executing a query that cannnot return rows\n            self.executeDDL1(cur)\n            self.assertRaises(self.driver.Error,cur.fetchone)\n\n            cur.execute('select name from %sbooze' % self.table_prefix)\n            self.assertEqual(cur.fetchone(),None,\n                'cursor.fetchone should return None if a query retrieves '\n                'no rows'\n                )\n            self.assertTrue(cur.rowcount in (-1,0))\n\n            # cursor.fetchone should raise an Error if called after\n            # executing a query that cannnot return rows\n            cur.execute(\"insert into %sbooze values ('Victoria Bitter')\" % (\n                self.table_prefix\n                ))\n            self.assertRaises(self.driver.Error,cur.fetchone)\n\n            cur.execute('select name from %sbooze' % self.table_prefix)\n            r = cur.fetchone()\n            self.assertEqual(len(r),1,\n                'cursor.fetchone should have retrieved a single row'\n                )\n            self.assertEqual(r[0],'Victoria Bitter',\n                'cursor.fetchone retrieved incorrect data'\n                )\n            self.assertEqual(cur.fetchone(),None,\n                'cursor.fetchone should return None if no more rows available'\n                )\n            self.assertTrue(cur.rowcount in (-1,1))\n        finally:\n            con.close()\n\n    samples = [\n        'Carlton Cold',\n        'Carlton Draft',\n        'Mountain Goat',\n        'Redback',\n        'Victoria Bitter',\n        'XXXX'\n        ]\n\n    def _populate(self):\n        ''' Return a list of sql commands to setup the DB for the fetch\n            tests.\n        '''\n        populate = [\n            \"insert into %sbooze values ('%s')\" % (self.table_prefix,s) \n                for s in self.samples\n            ]\n        return populate\n\n    def test_fetchmany(self):\n        con = self._connect()\n        try:\n            cur = con.cursor()\n\n            # cursor.fetchmany should raise an Error if called without\n            #issuing a query\n            self.assertRaises(self.driver.Error,cur.fetchmany,4)\n\n            self.executeDDL1(cur)\n            for sql in self._populate():\n                cur.execute(sql)\n\n            cur.execute('select name from %sbooze' % self.table_prefix)\n            r = cur.fetchmany()\n            self.assertEqual(len(r),1,\n                'cursor.fetchmany retrieved incorrect number of rows, '\n                'default of arraysize is one.'\n                )\n            cur.arraysize=10\n            r = cur.fetchmany(3) # Should get 3 rows\n            self.assertEqual(len(r),3,\n                'cursor.fetchmany retrieved incorrect number of rows'\n                )\n            r = cur.fetchmany(4) # Should get 2 more\n            self.assertEqual(len(r),2,\n                'cursor.fetchmany retrieved incorrect number of rows'\n                )\n            r = cur.fetchmany(4) # Should be an empty sequence\n            self.assertEqual(len(r),0,\n                'cursor.fetchmany should return an empty sequence after '\n                'results are exhausted'\n            )\n            self.assertTrue(cur.rowcount in (-1,6))\n\n            # Same as above, using cursor.arraysize\n            cur.arraysize=4\n            cur.execute('select name from %sbooze' % self.table_prefix)\n            r = cur.fetchmany() # Should get 4 rows\n            self.assertEqual(len(r),4,\n                'cursor.arraysize not being honoured by fetchmany'\n                )\n            r = cur.fetchmany() # Should get 2 more\n            self.assertEqual(len(r),2)\n            r = cur.fetchmany() # Should be an empty sequence\n            self.assertEqual(len(r),0)\n            self.assertTrue(cur.rowcount in (-1,6))\n\n            cur.arraysize=6\n            cur.execute('select name from %sbooze' % self.table_prefix)\n            rows = cur.fetchmany() # Should get all rows\n            self.assertTrue(cur.rowcount in (-1,6))\n            self.assertEqual(len(rows),6)\n            self.assertEqual(len(rows),6)\n            rows = [r[0] for r in rows]\n            rows.sort()\n          \n            # Make sure we get the right data back out\n            for i in range(0,6):\n                self.assertEqual(rows[i],self.samples[i],\n                    'incorrect data retrieved by cursor.fetchmany'\n                    )\n\n            rows = cur.fetchmany() # Should return an empty list\n            self.assertEqual(len(rows),0,\n                'cursor.fetchmany should return an empty sequence if '\n                'called after the whole result set has been fetched'\n                )\n            self.assertTrue(cur.rowcount in (-1,6))\n\n            self.executeDDL2(cur)\n            cur.execute('select name from %sbarflys' % self.table_prefix)\n            r = cur.fetchmany() # Should get empty sequence\n            self.assertEqual(len(r),0,\n                'cursor.fetchmany should return an empty sequence if '\n                'query retrieved no rows'\n                )\n            self.assertTrue(cur.rowcount in (-1,0))\n\n        finally:\n            con.close()\n\n    def test_fetchall(self):\n        con = self._connect()\n        try:\n            cur = con.cursor()\n            # cursor.fetchall should raise an Error if called\n            # without executing a query that may return rows (such\n            # as a select)\n            self.assertRaises(self.driver.Error, cur.fetchall)\n\n            self.executeDDL1(cur)\n            for sql in self._populate():\n                cur.execute(sql)\n\n            # cursor.fetchall should raise an Error if called\n            # after executing a a statement that cannot return rows\n            self.assertRaises(self.driver.Error,cur.fetchall)\n\n            cur.execute('select name from %sbooze' % self.table_prefix)\n            rows = cur.fetchall()\n            self.assertTrue(cur.rowcount in (-1,len(self.samples)))\n            self.assertEqual(len(rows),len(self.samples),\n                'cursor.fetchall did not retrieve all rows'\n                )\n            rows = [r[0] for r in rows]\n            rows.sort()\n            for i in range(0,len(self.samples)):\n                self.assertEqual(rows[i],self.samples[i],\n                'cursor.fetchall retrieved incorrect rows'\n                )\n            rows = cur.fetchall()\n            self.assertEqual(\n                len(rows),0,\n                'cursor.fetchall should return an empty list if called '\n                'after the whole result set has been fetched'\n                )\n            self.assertTrue(cur.rowcount in (-1,len(self.samples)))\n\n            self.executeDDL2(cur)\n            cur.execute('select name from %sbarflys' % self.table_prefix)\n            rows = cur.fetchall()\n            self.assertTrue(cur.rowcount in (-1,0))\n            self.assertEqual(len(rows),0,\n                'cursor.fetchall should return an empty list if '\n                'a select query returns no rows'\n                )\n            \n        finally:\n            con.close()\n    \n    def test_mixedfetch(self):\n        con = self._connect()\n        try:\n            cur = con.cursor()\n            self.executeDDL1(cur)\n            for sql in self._populate():\n                cur.execute(sql)\n\n            cur.execute('select name from %sbooze' % self.table_prefix)\n            rows1  = cur.fetchone()\n            rows23 = cur.fetchmany(2)\n            rows4  = cur.fetchone()\n            rows56 = cur.fetchall()\n            self.assertTrue(cur.rowcount in (-1,6))\n            self.assertEqual(len(rows23),2,\n                'fetchmany returned incorrect number of rows'\n                )\n            self.assertEqual(len(rows56),2,\n                'fetchall returned incorrect number of rows'\n                )\n\n            rows = [rows1[0]]\n            rows.extend([rows23[0][0],rows23[1][0]])\n            rows.append(rows4[0])\n            rows.extend([rows56[0][0],rows56[1][0]])\n            rows.sort()\n            for i in range(0,len(self.samples)):\n                self.assertEqual(rows[i],self.samples[i],\n                    'incorrect data retrieved or inserted'\n                    )\n        finally:\n            con.close()\n\n    def help_nextset_setUp(self,cur):\n        ''' Should create a procedure called deleteme\n            that returns two result sets, first the \n\t    number of rows in booze then \"name from booze\"\n        '''\n        raise NotImplementedError('Helper not implemented')\n        #sql=\"\"\"\n        #    create procedure deleteme as\n        #    begin\n        #        select count(*) from booze\n        #        select name from booze\n        #    end\n        #\"\"\"\n        #cur.execute(sql)\n\n    def help_nextset_tearDown(self,cur):\n        'If cleaning up is needed after nextSetTest'\n        raise NotImplementedError('Helper not implemented')\n        #cur.execute(\"drop procedure deleteme\")\n\n    def test_nextset(self):\n        con = self._connect()\n        try:\n            cur = con.cursor()\n            if not hasattr(cur,'nextset'):\n                return\n\n            try:\n                self.executeDDL1(cur)\n                sql=self._populate()\n                for sql in self._populate():\n                    cur.execute(sql)\n\n                self.help_nextset_setUp(cur)\n\n                cur.callproc('deleteme')\n                numberofrows=cur.fetchone()\n                assert numberofrows[0]== len(self.samples)\n                assert cur.nextset()\n                names=cur.fetchall()\n                assert len(names) == len(self.samples)\n                s=cur.nextset()\n                assert s == None,'No more return sets, should return None'\n            finally:\n                self.help_nextset_tearDown(cur)\n\n        finally:\n            con.close()\n\n    def test_nextset(self):\n        raise NotImplementedError('Drivers need to override this test')\n\n    def test_arraysize(self):\n        # Not much here - rest of the tests for this are in test_fetchmany\n        con = self._connect()\n        try:\n            cur = con.cursor()\n            self.assertTrue(hasattr(cur,'arraysize'),\n                'cursor.arraysize must be defined'\n                )\n        finally:\n            con.close()\n\n    def test_setinputsizes(self):\n        con = self._connect()\n        try:\n            cur = con.cursor()\n            cur.setinputsizes( (25,) )\n            self._paraminsert(cur) # Make sure cursor still works\n        finally:\n            con.close()\n\n    def test_setoutputsize_basic(self):\n        # Basic test is to make sure setoutputsize doesn't blow up\n        con = self._connect()\n        try:\n            cur = con.cursor()\n            cur.setoutputsize(1000)\n            cur.setoutputsize(2000,0)\n            self._paraminsert(cur) # Make sure the cursor still works\n        finally:\n            con.close()\n\n    def test_setoutputsize(self):\n        # Real test for setoutputsize is driver dependant\n        raise NotImplementedError('Driver need to override this test')\n\n    def test_None(self):\n        con = self._connect()\n        try:\n            cur = con.cursor()\n            self.executeDDL1(cur)\n            cur.execute('insert into %sbooze values (NULL)' % self.table_prefix)\n            cur.execute('select name from %sbooze' % self.table_prefix)\n            r = cur.fetchall()\n            self.assertEqual(len(r),1)\n            self.assertEqual(len(r[0]),1)\n            self.assertEqual(r[0][0],None,'NULL value not returned as None')\n        finally:\n            con.close()\n\n    def test_Date(self):\n        d1 = self.driver.Date(2002,12,25)\n        d2 = self.driver.DateFromTicks(time.mktime((2002,12,25,0,0,0,0,0,0)))\n        # Can we assume this? API doesn't specify, but it seems implied\n        # self.assertEqual(str(d1),str(d2))\n\n    def test_Time(self):\n        t1 = self.driver.Time(13,45,30)\n        t2 = self.driver.TimeFromTicks(time.mktime((2001,1,1,13,45,30,0,0,0)))\n        # Can we assume this? API doesn't specify, but it seems implied\n        # self.assertEqual(str(t1),str(t2))\n\n    def test_Timestamp(self):\n        t1 = self.driver.Timestamp(2002,12,25,13,45,30)\n        t2 = self.driver.TimestampFromTicks(\n            time.mktime((2002,12,25,13,45,30,0,0,0))\n            )\n        # Can we assume this? API doesn't specify, but it seems implied\n        # self.assertEqual(str(t1),str(t2))\n\n    def test_Binary(self):\n        b = self.driver.Binary('Something')\n        b = self.driver.Binary('')\n\n    def test_STRING(self):\n        self.assertTrue(hasattr(self.driver,'STRING'),\n            'module.STRING must be defined'\n            )\n\n    def test_BINARY(self):\n        self.assertTrue(hasattr(self.driver,'BINARY'),\n            'module.BINARY must be defined.'\n            )\n\n    def test_NUMBER(self):\n        self.assertTrue(hasattr(self.driver,'NUMBER'),\n            'module.NUMBER must be defined.'\n            )\n\n    def test_DATETIME(self):\n        self.assertTrue(hasattr(self.driver,'DATETIME'),\n            'module.DATETIME must be defined.'\n            )\n\n    def test_ROWID(self):\n        self.assertTrue(hasattr(self.driver,'ROWID'),\n            'module.ROWID must be defined.'\n            )\n\n"
  },
  {
    "path": "tests/default.cnf",
    "content": "# To create your own custom version of this file, read\n# http://dev.mysql.com/doc/refman/5.1/en/option-files.html\n# and set TESTDB in your environment to the name of the file\n\n[MySQLdb-tests]\nhost = 127.0.0.1\nuser = test\ndatabase = test\n#password =\ndefault-character-set = utf8\n"
  },
  {
    "path": "tests/test_MySQLdb_capabilities.py",
    "content": "#!/usr/bin/env python\r\nimport capabilities\r\nimport unittest\r\nimport MySQLdb\r\nimport warnings\r\n\r\nwarnings.filterwarnings('ignore')\r\n\r\nclass test_MySQLdb(capabilities.DatabaseTest):\r\n\r\n    db_module = MySQLdb\r\n    connect_args = ()\r\n    connect_kwargs = dict(use_unicode=True, sql_mode=\"ANSI,STRICT_TRANS_TABLES,TRADITIONAL\")\r\n    create_table_extra = \"ENGINE=INNODB CHARACTER SET UTF8\"\r\n    leak_test = False\r\n    \r\n    def quote_identifier(self, ident):\r\n        return \"`%s`\" % ident\r\n\r\n    def test_TIME(self):\r\n        from datetime import timedelta\r\n        def generator(row,col):\r\n            return timedelta(0, row*8000)\r\n        self.check_data_integrity(\r\n                 ('col1 TIME',),\r\n                 generator)\r\n\r\n    def test_TINYINT(self):\r\n        # Number data\r\n        def generator(row,col):\r\n            v = (row*row) % 256\r\n            if v > 127:\r\n                v = v-256\r\n            return v\r\n        self.check_data_integrity(\r\n            ('col1 TINYINT',),\r\n            generator)\r\n        \r\n    def test_stored_procedures(self):\r\n        db = self.connection\r\n        c = self.cursor\r\n        self.create_table(('pos INT', 'tree CHAR(20)'))\r\n        c.executemany(\"INSERT INTO %s (pos,tree) VALUES (%%s,%%s)\" % self.table,\r\n                      list(enumerate('ash birch cedar larch pine'.split())))\r\n        db.commit()\r\n        \r\n        c.execute(\"\"\"\r\n        CREATE PROCEDURE test_sp(IN t VARCHAR(255))\r\n        BEGIN\r\n            SELECT pos FROM %s WHERE tree = t;\r\n        END\r\n        \"\"\" % self.table)\r\n        db.commit()\r\n\r\n        c.callproc('test_sp', ('larch',))\r\n        rows = c.fetchall()\r\n        self.assertEquals(len(rows), 1)\r\n        self.assertEquals(rows[0][0], 3)\r\n        c.nextset()\r\n        \r\n        c.execute(\"DROP PROCEDURE test_sp\")\r\n        c.execute('drop table %s' % (self.table))\r\n\r\n    def test_small_CHAR(self):\r\n        # Character data\r\n        def generator(row,col):\r\n            i = (row*col+62)%256\r\n            if i == 62: return ''\r\n            if i == 63: return None\r\n            return chr(i)\r\n        self.check_data_integrity(\r\n            ('col1 char(1)','col2 char(1)'),\r\n            generator)\r\n    \r\n    def test_bug_2671682(self):\r\n        from MySQLdb.constants import ER\r\n        try:\r\n            self.cursor.execute(\"describe some_non_existent_table\");\r\n        except self.connection.ProgrammingError, msg:\r\n            self.assertEquals(msg[0], ER.NO_SUCH_TABLE)\r\n\r\n    def test_bug_3514287(self):\r\n        c = self.cursor\r\n        try:\r\n            c.execute(\"\"\"create table bug_3541287 (\r\n                c1 CHAR(10),\r\n                t1 TIMESTAMP)\"\"\")\r\n            c.execute(\"insert into bug_3541287 (c1,t1) values (%s, NOW())\",\r\n                (\"blah\",))\r\n        finally:\r\n            c.execute(\"drop table if exists bug_3541287\")\r\n\r\n    def test_ping(self):\r\n        self.connection.ping()\r\n        \r\n        \r\nif __name__ == '__main__':\r\n    if test_MySQLdb.leak_test:\r\n        import gc\r\n        gc.enable()\r\n        gc.set_debug(gc.DEBUG_LEAK)\r\n    unittest.main()\r\n"
  },
  {
    "path": "tests/test_MySQLdb_dbapi20.py",
    "content": "#!/usr/bin/env python\r\nimport dbapi20\r\nimport unittest\r\nimport MySQLdb\r\nfrom configdb import connection_kwargs\r\nimport warnings\r\nwarnings.simplefilter(\"ignore\")\r\n\r\nclass test_MySQLdb(dbapi20.DatabaseAPI20Test):\r\n    driver = MySQLdb\r\n    connect_args = ()\r\n    connect_kw_args = connection_kwargs(dict(sql_mode=\"ANSI,STRICT_TRANS_TABLES,TRADITIONAL\"))\r\n\r\n    def test_setoutputsize(self): pass\r\n    def test_setoutputsize_basic(self): pass\r\n    def test_nextset(self): pass\r\n\r\n    \"\"\"The tests on fetchone and fetchall and rowcount bogusly\r\n    test for an exception if the statement cannot return a\r\n    result set. MySQL always returns a result set; it's just that\r\n    some things return empty result sets.\"\"\"\r\n    \r\n    def test_fetchall(self):\r\n        con = self._connect()\r\n        try:\r\n            cur = con.cursor()\r\n            # cursor.fetchall should raise an Error if called\r\n            # without executing a query that may return rows (such\r\n            # as a select)\r\n            self.assertRaises(self.driver.Error, cur.fetchall)\r\n\r\n            self.executeDDL1(cur)\r\n            for sql in self._populate():\r\n                cur.execute(sql)\r\n\r\n            # cursor.fetchall should raise an Error if called\r\n            # after executing a a statement that cannot return rows\r\n##             self.assertRaises(self.driver.Error,cur.fetchall)\r\n\r\n            cur.execute('select name from %sbooze' % self.table_prefix)\r\n            rows = cur.fetchall()\r\n            self.assertTrue(cur.rowcount in (-1,len(self.samples)))\r\n            self.assertEqual(len(rows),len(self.samples),\r\n                'cursor.fetchall did not retrieve all rows'\r\n                )\r\n            rows = [r[0] for r in rows]\r\n            rows.sort()\r\n            for i in range(0,len(self.samples)):\r\n                self.assertEqual(rows[i],self.samples[i],\r\n                'cursor.fetchall retrieved incorrect rows'\r\n                )\r\n            rows = cur.fetchall()\r\n            self.assertEqual(\r\n                len(rows),0,\r\n                'cursor.fetchall should return an empty list if called '\r\n                'after the whole result set has been fetched'\r\n                )\r\n            self.assertTrue(cur.rowcount in (-1,len(self.samples)))\r\n\r\n            self.executeDDL2(cur)\r\n            cur.execute('select name from %sbarflys' % self.table_prefix)\r\n            rows = cur.fetchall()\r\n            self.assertTrue(cur.rowcount in (-1,0))\r\n            self.assertEqual(len(rows),0,\r\n                'cursor.fetchall should return an empty list if '\r\n                'a select query returns no rows'\r\n                )\r\n            \r\n        finally:\r\n            con.close()\r\n                \r\n    def test_fetchone(self):\r\n        con = self._connect()\r\n        try:\r\n            cur = con.cursor()\r\n\r\n            # cursor.fetchone should raise an Error if called before\r\n            # executing a select-type query\r\n            self.assertRaises(self.driver.Error,cur.fetchone)\r\n\r\n            # cursor.fetchone should raise an Error if called after\r\n            # executing a query that cannnot return rows\r\n            self.executeDDL1(cur)\r\n##             self.assertRaises(self.driver.Error,cur.fetchone)\r\n\r\n            cur.execute('select name from %sbooze' % self.table_prefix)\r\n            self.assertEqual(cur.fetchone(),None,\r\n                'cursor.fetchone should return None if a query retrieves '\r\n                'no rows'\r\n                )\r\n            self.assertTrue(cur.rowcount in (-1,0))\r\n\r\n            # cursor.fetchone should raise an Error if called after\r\n            # executing a query that cannnot return rows\r\n            cur.execute(\"insert into %sbooze values ('Victoria Bitter')\" % (\r\n                self.table_prefix\r\n                ))\r\n##             self.assertRaises(self.driver.Error,cur.fetchone)\r\n\r\n            cur.execute('select name from %sbooze' % self.table_prefix)\r\n            r = cur.fetchone()\r\n            self.assertEqual(len(r),1,\r\n                'cursor.fetchone should have retrieved a single row'\r\n                )\r\n            self.assertEqual(r[0],'Victoria Bitter',\r\n                'cursor.fetchone retrieved incorrect data'\r\n                )\r\n##             self.assertEqual(cur.fetchone(),None,\r\n##                 'cursor.fetchone should return None if no more rows available'\r\n##                 )\r\n            self.assertTrue(cur.rowcount in (-1,1))\r\n        finally:\r\n            con.close()\r\n\r\n    # Same complaint as for fetchall and fetchone\r\n    def test_rowcount(self):\r\n        con = self._connect()\r\n        try:\r\n            cur = con.cursor()\r\n            self.executeDDL1(cur)\r\n##             self.assertEqual(cur.rowcount,-1,\r\n##                 'cursor.rowcount should be -1 after executing no-result '\r\n##                 'statements'\r\n##                 )\r\n            cur.execute(\"insert into %sbooze values ('Victoria Bitter')\" % (\r\n                self.table_prefix\r\n                ))\r\n##             self.assertTrue(cur.rowcount in (-1,1),\r\n##                 'cursor.rowcount should == number or rows inserted, or '\r\n##                 'set to -1 after executing an insert statement'\r\n##                 )\r\n            cur.execute(\"select name from %sbooze\" % self.table_prefix)\r\n            self.assertTrue(cur.rowcount in (-1,1),\r\n                'cursor.rowcount should == number of rows returned, or '\r\n                'set to -1 after executing a select statement'\r\n                )\r\n            self.executeDDL2(cur)\r\n##             self.assertEqual(cur.rowcount,-1,\r\n##                 'cursor.rowcount not being reset to -1 after executing '\r\n##                 'no-result statements'\r\n##                 )\r\n        finally:\r\n            con.close()\r\n\r\n    def test_callproc(self):\r\n        pass # performed in test_MySQL_capabilities\r\n\r\n    def help_nextset_setUp(self,cur):\r\n        ''' Should create a procedure called deleteme\r\n            that returns two result sets, first the \r\n\t    number of rows in booze then \"name from booze\"\r\n        '''\r\n        sql=\"\"\"\r\n           create procedure deleteme()\r\n           begin\r\n               select count(*) from %(tp)sbooze;\r\n               select name from %(tp)sbooze;\r\n           end\r\n        \"\"\" % dict(tp=self.table_prefix)\r\n        cur.execute(sql)\r\n\r\n    def help_nextset_tearDown(self,cur):\r\n        'If cleaning up is needed after nextSetTest'\r\n        cur.execute(\"drop procedure deleteme\")\r\n\r\n    def test_nextset(self):\r\n        from warnings import warn\r\n        con = self._connect()\r\n        try:\r\n            cur = con.cursor()\r\n            if not hasattr(cur,'nextset'):\r\n                return\r\n\r\n            try:\r\n                self.executeDDL1(cur)\r\n                sql=self._populate()\r\n                for sql in self._populate():\r\n                    cur.execute(sql)\r\n\r\n                self.help_nextset_setUp(cur)\r\n\r\n                cur.callproc('deleteme')\r\n                numberofrows=cur.fetchone()\r\n                assert numberofrows[0]== len(self.samples)\r\n                assert cur.nextset()\r\n                names=cur.fetchall()\r\n                assert len(names) == len(self.samples)\r\n                s=cur.nextset()\r\n                if s:\r\n                    empty = cur.fetchall()\r\n                    self.assertEquals(len(empty), 0,\r\n                                      \"non-empty result set after other result sets\")\r\n                    #warn(\"Incompatibility: MySQL returns an empty result set for the CALL itself\",\r\n                    #     Warning)\r\n                #assert s == None,'No more return sets, should return None'\r\n            finally:\r\n                self.help_nextset_tearDown(cur)\r\n\r\n        finally:\r\n            con.close()\r\n\r\n    \r\nif __name__ == '__main__':\r\n    unittest.main()\r\n"
  },
  {
    "path": "tests/test_MySQLdb_nonstandard.py",
    "content": "import unittest\n\nimport _mysql\nimport MySQLdb\nfrom MySQLdb.constants import FIELD_TYPE\nfrom configdb import connection_factory\nimport warnings\nwarnings.simplefilter(\"ignore\")\n\nclass TestDBAPISet(unittest.TestCase):\n    def test_set_equality(self):\n        self.assertTrue(MySQLdb.STRING == MySQLdb.STRING)\n\n    def test_set_inequality(self):\n        self.assertTrue(MySQLdb.STRING != MySQLdb.NUMBER)\n\n    def test_set_equality_membership(self):\n        self.assertTrue(FIELD_TYPE.VAR_STRING == MySQLdb.STRING)\n\n    def test_set_inequality_membership(self):\n        self.assertTrue(FIELD_TYPE.DATE != MySQLdb.STRING)\n\n\nclass CoreModule(unittest.TestCase):\n    \"\"\"Core _mysql module features.\"\"\"\n\n    def test_NULL(self):\n        \"\"\"Should have a NULL constant.\"\"\"\n        self.assertEqual(_mysql.NULL, 'NULL')\n\n    def test_version(self):\n        \"\"\"Version information sanity.\"\"\"\n        self.assertTrue(isinstance(_mysql.__version__, str))\n\n        self.assertTrue(isinstance(_mysql.version_info, tuple))\n        self.assertEqual(len(_mysql.version_info), 5)\n\n    def test_client_info(self):\n        self.assertTrue(isinstance(_mysql.get_client_info(), str))\n\n    def test_thread_safe(self):\n        self.assertTrue(isinstance(_mysql.thread_safe(), int))\n\n\nclass CoreAPI(unittest.TestCase):\n    \"\"\"Test _mysql interaction internals.\"\"\"\n\n    def setUp(self):\n        self.conn = connection_factory(use_unicode=True)\n\n    def tearDown(self):\n        self.conn.close()\n\n    def test_thread_id(self):\n        tid = self.conn.thread_id()\n        self.assertTrue(isinstance(tid, int),\n                        \"thread_id didn't return an int.\")\n\n        self.assertRaises(TypeError, self.conn.thread_id, ('evil',),\n                          \"thread_id shouldn't accept arguments.\")\n\n    def test_affected_rows(self):\n        self.assertEquals(self.conn.affected_rows(), 0,\n                          \"Should return 0 before we do anything.\")\n\n\n    #def test_debug(self):\n        ## FIXME Only actually tests if you lack SUPER\n        #self.assertRaises(MySQLdb.OperationalError,\n                          #self.conn.dump_debug_info)\n\n    def test_charset_name(self):\n        self.assertTrue(isinstance(self.conn.character_set_name(), str),\n                        \"Should return a string.\")\n\n    def test_host_info(self):\n        self.assertTrue(isinstance(self.conn.get_host_info(), str),\n                        \"Should return a string.\")\n\n    def test_proto_info(self):\n        self.assertTrue(isinstance(self.conn.get_proto_info(), int),\n                        \"Should return an int.\")\n\n    def test_server_info(self):\n        self.assertTrue(isinstance(self.conn.get_server_info(), str),\n                        \"Should return an str.\")\n\n"
  },
  {
    "path": "tests/travis.cnf",
    "content": "# To create your own custom version of this file, read\n# http://dev.mysql.com/doc/refman/5.1/en/option-files.html\n# and set TESTDB in your environment to the name of the file\n\n[MySQLdb-tests]\nhost = 127.0.0.1\nuser = root\ndatabase = mysqldb_test\n#password =\ndefault-character-set = utf8mb4\n"
  },
  {
    "path": "tox.ini",
    "content": "[tox]\nenvlist = py25, py26, py27, py33\n\n[testenv]\nsetenv =\n    TESTDB=travis.cnf\ncommands =\n    nosetests {posargs:-w tests -v}\ndeps =\n    ipdb\n    nose\n"
  }
]