MySQL connection to mysqldb in Python

Source: Internet
Author: User

1. Download mysql-Python plugin from the Operating System

2. Double-click to install mysqldb.

3. Import mysqldb. AppearsFile "C:/python26/lib/Site-packages/mysqldb/_ init _. py", line 19, in <module>
Importerror: DLL load failed: the specified module cannot be found.Is missing two DLL files: libguide40.dll and libmmd. dll. Download the package and copy it to Windows/system32 or python26/lib/Site-packages.

4. Import mysqldb. AgainSYS: 1: deprecationwarning: The sets module is deprecatedError, search again, because 2.6 does not know the sets module, but the set built-in function has been added. Locate _ init _. py in the mysqldb folder and comment outFrom Sets Import immutableset
Class dbapiset (immutableset ):AddClass dbapiset (frozenset ):Find converters. py and comment out from sets import baseset and set. Then, set the values of rows 45th and 129 to set.

5. Import mysqldb
Conn = mysqldb. Connect (host = "localhost", user = "root", passwd = "root", DB = "test ")

Connection successful MySQL use API: http://mysql-python.sourceforge.net/MySQLdb.html

 

 

Attachment: related installation files and DLL after finishing download http://download.csdn.net/source/3080072

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.