手机
当前位置:查字典教程网 >脚本专栏 >python >python连接MySQL数据库实例分析
python连接MySQL数据库实例分析
摘要:本文实例讲述了python连接MySQL数据库的方法。分享给大家供大家参考。具体实现方法如下:importMySQLdbconn=MySQL...

本文实例讲述了python连接MySQL数据库的方法。分享给大家供大家参考。具体实现方法如下:

import MySQLdb conn = MySQLdb.connect(host="localhost", user="root", passwd="123456", db="test") cursor = conn.cursor() cursor.execute("select * from hard") res = cursor.fetchall() for x in res: print x cursor.close() conn.close()

运行结果如下:

python连接MySQL数据库实例分析1

希望本文所述对大家的python程序设计有所帮助。

【python连接MySQL数据库实例分析】相关文章:

Python学习笔记_数据排序方法

Python读写Redis数据库操作示例

python连接MySQL、MongoDB、Redis、memcache等数据库的方法

Python SQLite3数据库操作类分享

python重试装饰器示例

python算法学习之计数排序实例

python缩进区别分析

python操作MySQL数据库具体方法

python实现bitmap数据结构详解

python求斐波那契数列示例分享

精品推荐
分类导航