python+gadfly 我的测试程序

      在安装gadfly的时候,虽然看了安装文件,但还是感觉无从下手,于是就直接运行了setup.py ,然后把gadfly文件夹直接复制到了Karrigell-2.4.0/database/目录下竟然就能用了,呵呵!!!

     心情不错!!!

import gadfly
cx = gadfly.gadfly()
cx.startup( "persons","C:\/\/Karrigell240\/Karrigell-2.4.0\/databases\/" )
sql = "CREATE TABLE Person ( name varchar, surname varchar, age integer, info varchar )"
cursor = cx.cursor()
cursor.execute( sql )

cursor.execute("INSERT INTO Person (name,surname,age,info) values ('caulfield','holden','18','catcher in the rye')"  )
cx.commit()

 

sql = "SELECT name, surname, age, info FROM Person WHERE name='caulfield'"
cursor.execute(sql)
res=cursor.fetchall()[0]
print res[0]
print res[1]
print res[2]
print res[3]

posted @ 2008-04-22 13:29  曹振华  阅读(2402)  评论(0编辑  收藏  举报