Chinaunix首页 | 论坛 | 博客
  • 博客访问: 226438
  • 博文数量: 66
  • 博客积分: 2510
  • 博客等级: 少校
  • 技术积分: 700
  • 用 户 组: 普通用户
  • 注册时间: 2009-07-27 22:10
个人简介

闲时会写写程序的非技术人员。

文章分类

全部博文(66)

文章存档

2022年(1)

2018年(11)

2011年(1)

2010年(36)

2009年(17)

我的朋友

分类: Python/Ruby

2018-09-04 15:46:40



PyMySQL 是纯 Python 实现的驱动,速度上比不上 MySQLdb,最大的特点可能就是它的安装方式没那么繁琐,同时也兼容 MySQL-python

1
2
3
pip install PyMySQL
# 为了兼容mysqldb,只需要加入
pymysql.install_as_MySQLdb()

一个例子

1
2
3
4
5
6
7
8
import pymysql
conn = pymysql.connect(host='127.0.0.1', user='root', passwd="xxx", db='mysql')
cur = conn.cursor()
cur.execute("SELECT Host,User FROM user")
for r in cur:
  print(r)
cur.close()
conn.close()
阅读(609) | 评论(0) | 转发(0) |
0

上一篇:anaconda 配置 tushare

下一篇:centos 配置docker

给主人留下些什么吧!~~