MySQL pymysql module

Source: Internet
Author: User

Installing PIP3 install Pymysql on the cmd command line

If the installation is successful, the database can be pycharm and checked in the operation.

Import pymysql# Module # CREATE link conn=Pymysql.connect (Host='127.0.0.1', Port=3306, the user='Root', Password='123', Database='DB6', CharSet='UTF8') Conn=pymysql.connect (host='127.0.0.1', port=3306, user='Root', password='123', database='DB6', charset='UTF8') #创建游标cursor=Conn.cursor () # Executes SQL and returns the number of rows affected # rows=cursor.execute ("SELECT * from UserInfo"# Print (rows) #执行SQL and returns the number of affected rows executed multiple times rows1=cursor.executemany ("INSERT INTO UserInfo (Uname,password) VALUES (%s,%s)",[("Egon",123456),("Alex",123]) print (ROWS1) #提交, you cannot save the newly created or modified data conn.commit () #关闭游标cursor. Close () #关闭连接conn. Close ()

MySQL pymysql module

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.