One-click connection to the mysql driver using python (for windows) and pythonmysql

Source: Internet
Author: User

One-click connection to the mysql driver using python (for windows) and pythonmysql

I spent one afternoon on the mysql driver and shared the solution.

1: manually install the driver
This is a nightmare. We recommend that you use automatic installation.
2: Automatic Installation
Download the automatic installation package, http://www.bkjia.com/softs/73369.html

Double-click to install! After installation is complete. You can operate the database normally.
Eg:
Import mysqldb
Con = mysqldb. connect (host = 'localhost', user = 'root', passwd = 'root', db = 'test ')
Cursor = con. cursor ()
SQL = "select * from test"
Cursor.exe cute (SQL)
Alldata = cursor. fetchall ()
If alldata:
For rec in alldata:
Print rec [0]
Cursor. close ()
Con. close ()

If a friend uses pydev in eclispe, the import mysqldb will fail because eclipse cannot identify the driver automatically. If you use this method, please use Baidu.

Two drivers are available for windows. For other versions, download them from the official website.

: Https://pypi.python.org/pypi/MySQL-python/

Related Article

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.