1. python安装mysql

$ pip install mysql-python

2. 数据库连接程序:

import MySQLdb

# 打开数据库连接
db = MySQLdb.connect(host="vpca-1.vm.elenet.me",port=9707, user="vpca_user",passwd="123456",db="vpca_db")

# 使用cursor()方法获取操作游标
cursor = db.cursor()

# 使用execute方法执行SQL语句
cursor.execute("SELECT * FROM tb_name limit 1;")

# 使用 fetchone() 方法获取一条数据库。
data = cursor.fetchone()

print data

# 关闭数据库连接
db.close()

最新文章

  1. python27 ImportError: No module named site
  2. c语言之【#ifdef】
  3. Win7上安装Linux双系统
  4. redis数据结构整理(二)
  5. 从电商平台促销活动看电商app开发趋势
  6. undefined reference to `pthread_create'问题解决
  7. NServiceBus教程-持久化
  8. Ubuntu14.04下中山大学锐捷上网设置
  9. JavaScript跨站脚本攻击
  10. MYSQL数据库备份与恢复
  11. 原生 JavaScript 代码和Jquery实现对比
  12. 一定要学会OutputDebugString,方便源码级调试
  13. nginx做反向负载均衡,后端服务器获取真实客户端ip
  14. SpringCloud的Hystrix(一) 一个消费者内的两个服务监控
  15. THUWC2019 GG记
  16. 我的 FPGA 学习历程(14)—— PWM 脉冲宽度调制
  17. protobuf是什么?
  18. C语言复习6_doWhile循环
  19. IOS Xcode编译项目-报错“ld: library not found for -XX”
  20. 游戏中转盘概率的算法---python实现

热门文章

  1. jdk锁相关
  2. Redis-SDS
  3. javascript之url转义escape()、encodeURI()和decodeURI(),ifram父子传参参数有中文时出现乱码
  4. redux、immutablejs和mobx性能对比(三)
  5. JS全国城市三级联动
  6. Remove Duplicates from Sorted List 去除链表中重复值节点
  7. Java 设计模式(三)-单例模式(Singleton Pattern)
  8. 安装Xcode主题
  9. [翻译] MGConferenceDatePicker
  10. django导入/导出原始数据