标签:nec log for obj license bsp info div odi
1.MySQLdb 是用于Python链接Mysql数据库的接口,它实现了 Python 数据库 API 规范 V2.0,基于 MySQL C API 上建立的。
2.Python下MySQLdb安装。
(1)先下载MySQLdb安装包,解压。
(2)cmd以管理员身份运行,进行MySQLdb目录,将MySQLdb安装至Python下:python setup.py install
He.py代码:
#coding=utf-8 import pymysql conn=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() for dr in rows: print(dr)
调用代码:
Python 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 17:54:52) [MSC v.1900 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> from jinjiemysql import * (7, ‘VB.NET‘, ‘VB.NET‘) (3, ‘go go‘, ‘er3r53r5‘) (4, ‘ C#‘, ‘RWRRWWW‘) (6, ‘object c‘, ‘object c‘) (5, ‘python‘, ‘haaaa‘) >>>
标签:nec log for obj license bsp info div odi
原文地址:http://www.cnblogs.com/joyet-john/p/7087452.html