首页 | 源码下载 | 网站模板 | 网页特效 | 广告代码 | 网页素材 | 字体下载 | 书库
会员投稿 投稿指南 RSS订阅
当前位置:主页>网络编程>Mysql教程>资讯:Python处理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测试程序
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()

= cur.execute('insert into people values(6,\'Bill Gates\',58,\'M\')')
cur.execute(
'delete from people where age=58')
conn.commit()

= cur.execute('select * from people')
= cur.fetchall()
print r

上一篇:mysql5在rhel5下乱码问题及解决方法 下一篇:如何用MySQL-Front远程连接MySql?

评论总数:0 [ 查看全部 ] 网友评论


关于我们隐私版权广告服务友情链接联系我们网站地图