栏目导航
热点推荐
- mysql排序的妙用(类似置顶)
- 优化MySQL的数据库性能的八种方
- MySQL配置文件my.cnf中文版
- linux下mysql命令
- 如何用MySQL-Front远程连接MySql
- 如何修改MySQL 5.1 data文件夹路
- Linux mysql安装修改root密码服
- MySQL Server 5.0安装教程(图解)
- PHP中的MYSQL常用函数
- mysql常见错误提示及解决方法
- MySQL常见错误问答!
- 使用MySQL时的一些常见错误
阅览排行
Python处理mysql数据库
www.jz123.cn 2010-12-03 来源: 站长家园 责任编辑(袁袁) 我要投递新闻
use mysql;
update user set password=password('Oracle11g') where user='root';
flush privileges;
---------------------
create database myfamily;
use myfamily;
create table people(id int, name varchar(30), age int, sex char(1));
insert into people values(0,'Zihao Xu',5,'M');
select * from people;exit;3、编写pyMysql.py测试程序
update user set password=password('Oracle11g') where user='root';
flush privileges;
---------------------
create database myfamily;
use myfamily;
create table people(id int, name varchar(30), age int, sex char(1));
insert into people values(0,'Zihao Xu',5,'M');
select * from people;exit;3、编写pyMysql.py测试程序
phoenix@debian:~$ cat pyMysql.py
#!/usr/bin/python
#filename:pyMysql.py
#coding:utf-8
import MySQLdb
conn = MySQLdb.connect(host='127.0.0.1', db='myfamily',
user='root', passwd='Oracle11g')
cur = conn.cursor()
r = cur.execute('insert into people values(6,\'Bill Gates\',58,\'M\')')
cur.execute('delete from people where age=58')
conn.commit()
r = cur.execute('select * from people')
r = cur.fetchall()
print r
#!/usr/bin/python
#filename:pyMysql.py
#coding:utf-8
import MySQLdb
conn = MySQLdb.connect(host='127.0.0.1', db='myfamily',
user='root', passwd='Oracle11g')
cur = conn.cursor()
r = cur.execute('insert into people values(6,\'Bill Gates\',58,\'M\')')
cur.execute('delete from people where age=58')
conn.commit()
r = cur.execute('select * from people')
r = cur.fetchall()
print r
0
上一篇:mysql5在rhel5下乱码问题及解决方法 下一篇:如何用MySQL-Front远程连接MySql?