Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1344070
  • 博文数量: 243
  • 博客积分: 888
  • 博客等级: 准尉
  • 技术积分: 2955
  • 用 户 组: 普通用户
  • 注册时间: 2012-12-05 14:33
个人简介

漫漫长路,其修远兮!

文章分类

全部博文(243)

文章存档

2017年(2)

2016年(22)

2015年(32)

2014年(57)

2013年(107)

2012年(23)

分类: Python/Ruby

2014-03-31 15:46:04

1.安装方式
sudo easy_install Torndb

2.连接数据库

点击(此处)折叠或打开

  1. db=torndb.Connection(host+":"+str(port),db,user=user,password=pwd)

  2. cre_sql="create table blog(id int,content text)"
  3. db.execute(cre_sql)
  4. string='wawuee'
  5. exe='insert into blog(id,content)values(%d,"%s")'%(1,string)
  6. db.execute(exe)

  7. a=db.get('select * from blog where id=1')
  8. print a

  9. b=db.query('select * from blog')
  10. print b


阅读(5562) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

mylusing2015-01-07 16:23:09

如何断开连接?自带的close方法用了之后还是可以访问数据库。