Python操作MySQL数据库
来源:互联网 发布:高速公路收费查询软件 编辑:程序博客网 时间:2024/05/22 17:36
#coding=utf-8import MySQLdbimport MySQLdb.cursorsconn= MySQLdb.connect( host='localhost', port = 3306, user='root', passwd='root', db ='test', cursorclass = MySQLdb.cursors.DictCursor, charset='utf8')cur = conn.cursor()#创建数据表#cur.execute("create table student(id int ,name varchar(20),class varchar(30),age varchar(10))")#插入一条数据#cur.execute("insert into student values('2','Tom','3 year 2 class','9')")#修改查询条件的数据#cur.execute("update student set class='3 year 1 class' where name = 'Tom'")#删除查询条件的数据#cur.execute("delete from student where age='9'")cur.execute('select name from student')for data in cur.fetchall(): print data['name'] conn.commit()cur.close()conn.close()
阅读全文
1 0
- Python操作Mysql数据库
- python操作MySQL数据库
- python操作MySQL数据库
- python操作MySQL数据库
- python操作MySQL数据库
- python操作MySQL数据库
- python操作MySQL数据库
- python操作MySQL数据库
- python操作MySQL数据库
- python操作MySQL数据库
- python 操作mysql 数据库
- python操作mysql数据库
- python 操作 mysql数据库
- python操作MySQL数据库
- python操作MySQL数据库
- Python操作MySQL数据库
- Python操作mysql数据库
- python操作MySQL数据库
- 作为潮汕人你了解肠粉么 附带家常肠粉做法
- Android 判断系统默认存储位置是“内置存储卡”还是“SD卡”
- 史上最详细的vsftpd配置文件讲解
- 本地如何搭建IPv6环境测试你的APP ---
- 西瓜书《机器学习》阅读笔记6——Chapter3_公式(3.27)的推导过程
- Python操作MySQL数据库
- CodeForces
- 企业微信内自创建app 获取用户信息问题
- 设计模式之创建型模式(2)--工厂模式
- MyBatis-Spring整合 注入SqlSessionTemplate
- GPU异构编程模型
- Struts2上传文件的最大Size的设置
- HDU 2005
- Android TextView 改变字体方法