Python Learning (Python) operation MySQL Database _ installation

Source: Internet
Author: User

python3.4 connection MySQL database under Win7 system

1. Download the latest Python program to the official Python website. According to the system there are 32, 64 bits.

Directly next, you can install successfully.

2. Download the ez_setup.py file in the Python website.

This tool is a Python Management Pack tool that allows you to download many services.

Please download the relevant files according to the system.

Download the ez_setup.py file in the https://pypi.python.org/pypi/setuptools#windows-simplified URL.

3. Execute the python ez_setup.py file in Python, and if you do not configure an environment variable, you can find Python.exe in the Python installation path to execute the above command in this directory.

After the command executes successfully, the Easy_install.exe Toolkit is installed in the Python installation directory

4. Execute at cmd command line: Easy_install.exe PYMYSQL3

If the command is not found, the switch service is executed under the Python installation directory/scripts/. If there is no easy_install.exe in this directory, it proves that the previous step was not successfully installed.

5.

The contents of the Python program are as follows: Import Pymysql

conn = Pymysql.connect (user= ' root ', passwd= ' root ',

host= ' localhost ', db= ' zjctest ')

cur = conn.cursor ()

Cur.execute ("SELECT * from ZJC")

For R in Cur:

Print ("Row_number:", (Cur.rownumber))

Print ("ID:" +str (r[0]) + "Name:" +str (r[1]) + "Age:" +str (r[2))

Cur.close ()

Conn.close ()

Python Learning (Python) operation MySQL Database _ installation

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.