2014-02-21 28 views
0

我試圖從返回數據庫對象中獲取字段名稱和記錄值。我有一個datahandler.py文件查詢exection。當我從一個源文件中找到一個數據處理器方法(比如GetEmployeeinfo(id))時,它返回一個對象。我想知道如何從GetEmployeeinfo(id)返回的對象中獲取字段名稱和記錄線索。如何從返回對象中獲取字段名稱和記錄

mycode的是這樣的:

Employee.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文件將其返回到呈現頁面。

在此先感謝。

+0

閱讀它的employeeinfo的文檔,看看有什麼屬性,它類可能有 – zhangxaochen

+0

實際方法GetEmployeeinfo()返回employeeinfo(表名)實例 – Nirmala

+0

是看錶類(即包裝類我猜)的從屬性文檔 – zhangxaochen

回答

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>以查看代碼完成。
+0

感謝您的幫幫我。有效。 – Nirmala