安装 

pip install mysqlclient

连接数据库

db = MySQLdb.connect(host="IP",port=端口,user="账号",password='密码', db='数据库',charset='编码格式')

创建一个游标对象

cursor = db.cursor()

执行语句,不返回结果

cursor.execute("SQL语句")

提交语句

connection.commit()

返回多条数据

res = cursor.fetchall()
for data in res:
  print(data) 返回单条数据 result = cursor.fetchone() 关闭数据库 db.close()

最新文章

  1. EntityFramework linq 多条件查询,不定条件查询
  2. js在控件原有的事件方法中加入自己的方法
  3. cocospod 安装和使用 podfile 问题解决
  4. order by调优的一些测试
  5. MapReduce输出格式
  6. Unity3D NGUI制作进度条
  7. 从Delphi 7升级到Delphi XE
  8. 【最小费用最大流模板】【Uva10806+Spring Team PK】Dijkstra, Dijkstra,
  9. nginx基础入门
  10. OC画笔CGContextRef
  11. spring boot / cloud (八) 使用RestTemplate来构建远程调用服务
  12. 自学OpenCV时遇到的一些错误(捂脸ing,当年确实好多不懂...)
  13. Luogu1121:环状最大两段子段和
  14. jmap -histo pid 输出的[C [B [I [S methodKlass constantPoolKlass含义
  15. EL表达式JSTL
  16. 原生JavaScript运动功能系列(三):多物体多值运动
  17. 在Windows上弄一个redis的docker容器
  18. ios开发之--把秒转换为天时分秒
  19. Android 利用广播接收器启动服务
  20. HDU5003:Osu!(签到题)HDU5038:(签到题,题意很坑)

热门文章

  1. mysql权限参考
  2. Previous operation has not finished;run 'cleanup' if it was interrupted;Please execute the 'Cleanup' command.
  3. html5 的存储
  4. Ubuntu系统建立交叉编译环境
  5. 常被问到的十个 Java 面试题
  6. 微信公众号手机无法直接下载APK文件是怎么回事
  7. week6
  8. Object.prototype.toString.call() 、 instanceof 以及 Array.isArray()判断数组的方法的优缺点
  9. my goal
  10. C# WebAPI分页实现分享