python连接mysql查询数据示例,pythonmysql,使用MySQLdb模块连
python连接mysql查询数据示例,pythonmysql,使用MySQLdb模块连
使用MySQLdb模块连接MySQL```python
coding=utf-8
引入mysql python客户端模块
import MySQLdbimport sys
进行数据库连接
conn = MySQLdb.connect(host="localhost", user="root", passwd="123456", db="pythontab", charset="utf8")cursor = conn.cursor()
执行sql
cursor.execute("select * from test")
列出数据
records = cursor.fetchall()for row in records: for r in row: print r```
相关内容
- python获取mp3文件信息,,将代码生成.py文件放在
- Python分段下载文件,python分段,下载较大文件时分段下载
- 400行python 实现http/https 代理服务器,400行python,#!/usr/b
- 自动配置Google Hosts脚本,googlehosts脚本,#!/usr/bin/e
- 什么值得买签到脚本,值得买签到脚本,#coding=utf-
- 进程监控的python脚本,监控python脚本,NoneSendMail
- Python使用Gmail发邮件,pythongmail发邮件,有时候需要备份
- 原 第三方Linux版网易云音乐 更新 2015-8-10,linux2015-8-1
- tkinter 编写文件字符串替换,tkinter字符串,__author__ =
- python通过ssh-powershell监控windows,,对于服务器的监控来说
评论关闭