Questions about Pymysql installation in MySQL.

Source: Internet
Author: User

In general, we enter directly in the terminal:

PIP3 Install Pymysql

will be able to install successfully automatically.

But sometimes we have to specify a Python interpreter first:

For example we specify Python3 in terminal cmd input:  python3 -m pip install Pymysql on the line ..... 

After the installation is successful, we can import the Pymysql directly into the PYCAHRM:

Import pymysql #pip3 install Pymysqlconn=Pymysql.connect (Host='127.0.0.1', Port=3306, the user='Root', Password='123', Database='db42', CharSet='UTF8') Cursor=Conn.cursor (pymysql.cursors.DictCursor) # rows=cursor.execute ('show tables;') Rows=cursor.execute ('SELECT * from class;') print (rows) # print (Cursor.fetchone ()) # Print (Cursor.fetchone ()) # Print (Cursor.fetchmany (2) # Print (Cursor.fetchall ()) # Print (Cursor.fetchall ()) # Print (Cursor.fetchall ()) # Cursor.scroll (3,'Absolute') # Print (Cursor.fetchone ()) print (Cursor.fetchone ()) print (Cursor.fetchone ()) Cursor.scroll (1,'relative') Print (Cursor.fetchone ()) Cursor.close () conn.close ()

Questions about Pymysql installation in MySQL.

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.