Access the MySQL 2.7 database on the Python 5.0 platform

Source: Internet
Author: User

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:

  1. '''
  2. Created on 2011-11-29
  3. @ Author: LONMID
  4. '''
  5. Import MySQLdb
  6. Conn=MySQLdb. Connect (User='Root',Passwd='123',Db='Example');
  7. Cur=Conn. Cursor ();
  8. Cur.exe cute ("select id, lastname, firstname, date_format (dob, '% Y-% m-% d % H-% I-% s '), phone from employee ");
  9. # Select username, password, date_format (reg_date, '% Y-% m-% d % H-% I-% s') as date from reg_user
  10. For data in cur. fetchall ():
  11. Print data;
  12. Cur. close ();
  13. Conn. commit ();
  14. Conn. close ();

If no error is reported, mysql can be used.

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.