0

我正在尝试从返回的数据库对象中获取字段名称和记录值。我有一个用于查询执行的 datahandler.py 文件。当我从一个源文件中点击数据处理程序方法(例如GetEmployeeinfo(id))时,它返回一个对象。我想知道如何从 GetEmployeeinfo(id) 返回的对象中获取字段名称和记录值。

MyCode 看起来像这样:

雇员.py

 class EmployeeForm(BrowserView)

 def getEmployee(self):
    handler=self.MyDBHandler()
    emp_info=handler.GetEmployeeinfo(id=1) // this return the object from a 
                                              GetEmployeeinfo(id)
    return emp_info

dbhandler.py

  class MyDBhandler():

  def GetEmployeeinfo(id,dic=0)
    //some select statement query goes here 
     return []
    // it return the object instance like "<My.Product.dbhandler.xxxx>"

我想知道如何从 Employee.py 文件中的返回对象中获取字段名称和记录,以将其返回到渲染页面。

提前致谢。

4

1 回答 1

0
  1. 只要您有一个,就阅读该课程的文档。
  2. print help(My.Product.dbhandler.xxxx)查看该类的帮助信息,或用于print dir(My.Product.dbhandler.xxxx)查看该类的属性和方法。
  3. 如果您有一些 IDE(例如带有 pyDev 的 eclipse)或带有自动完成功能的增强型 shell/编辑器(例如 iPython) ,只需键入My.Product.dbhandler.xxxx.<TAB>即可查看代码完成。
于 2014-02-21T13:34:05.313 回答