Python basics of MySQL

Source: Internet
Author: User

1.MYSQLDB is the interface for the Python link MySQL database, which implements the Python database API specification V2.0, built on the MySQL C API.

2.Python under MYSQLDB installation.

(1) First download MYSQLDB installation package, unzip.

(2) CMD runs as administrator, makes MySQLdb directory, installs mysqldb under Python: Python setup.py install

he.py Code:

#Coding=utf-8ImportPymysqlconn=pymysql.connect (host="127.0.0.1", port=3306,user="Root", passwd="Root", db="Dgcms", charset="UTF8") cur=conn.cursor () SQL="select * FROM blog"cur.execute (SQL) rows=Cur.fetchall () forDrinchrows:Print(DR)

Calling code:

Python 3.6.1 (V3.6.1:69C0DB5, Mar, 17:54:52) [MSC v.1900 32bit (Intel)] on Win32type"Copyright","credits" or "license ()"  forMore information.>>> fromJinjiemysqlImport*(7,'vb.net','vb.net')(3,'Go Go','ER3R53R5')(4,'C #','rwrrwww')(6,'Object C','Object C')(5,'python','haaaa')>>>

Python basics of 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.