In other words, download mysql-python-1.2.3.win32-py2.7.exe
Is:
Free in http://linux.bkjia.com/
The username and password are both www.bkjia.com
The specific download directory is/pub/2011/12/07/access the MySQL 2.7 database on the Python 5.0 platform/
You can find the installation package in it. After installation, it will automatically install the mysql file in python 2.7/lib/site-package. After installation, no other configuration will be made, you can use it directly.
The following is an example to illustrate how to use python to access the mysql database,
See the following example:
- '''
- Created on 2011-11-29
- @ Author: LONMID
- '''
- Import MySQLdb
- Conn=MySQLdb. Connect (User='Root',Passwd='123',Db='Example');
- Cur=Conn. Cursor ();
- Cur.exe cute ("select id, lastname, firstname, date_format (dob, '% Y-% m-% d % H-% I-% s '), phone from employee ");
- # Select username, password, date_format (reg_date, '% Y-% m-% d % H-% I-% s') as date from reg_user
- For data in cur. fetchall ():
- Print data;
- Cur. close ();
- Conn. commit ();
- Conn. close ();
If no error is reported, mysql can be used.