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.