Friday, February 25, 2011

#Python microframework web.py and #firebird tutorial

I assume that Firebird 2.5 and python driver are installed (I use ubuntu for this tutorial)

I will start with the simple db employee from examples also i will use as starting point the web.py tutorial

First create a database and one table (insert one row)
import web
db=web.database(dbn='firebird',db='localhost:/tmp/test.fdb',user='sysdba',password='masterkey')
#this is a most to open transaction or else you will get cursor not open
t=db.transaction()
db.query("create table person (name varchar(255), email varchar(255))")
t.commit()
db.query("insert into person (name, email) values ('Random Name','example@example.com')")
t.commit()
Then query the table already created

import web
db=web.database(dbn='firebird',db='localhost:/tmp/test.fdb',user='sysdba',password='masterkey')
#this is a most to open transaction or else you will get cursor not open
db.transaction()
result=db.query("select * from person")
#result=db.select('person')
print result[0]


Later we will create a grid like in the web.py group thread

No comments: