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