twistedsimple.py

1206阅读 0评论2010-11-30 atyu30
分类:Oracle

#File: twistedsimple.py
#A simplified Twisted app
from twisted.internet import reactor
from twisted.enterprise import adbapi
 
def printResult(rslt):
   print rslt[0][0]
   reactor.stop()
 
if __name__ == "__main__":
   dbpool = adbapi.ConnectionPool('cx_Oracle', user='hr', password ='hr', dsn='127.0.0.1/XE')
   empno = 100
   deferred = dbpool.runQuery("SELECT last_name FROM employees WHERE employee_id = :empno", {'empno':empno})
   deferred.addCallback(printResult)
   reactor.run()
 
上一篇:synchmultithread.py
下一篇:twistedTCPServer.py