def ReturnInfo(self, avalue, akey):
cursor = connection.cursor()
if type(avalue) == int:
Sql = "select * from %s where %s=%s" % (self.table, akey, avalue)
else:
Sql = "select * from %s where %s = '%s'" % (self.table, akey, avalue)
cursor.execute(Sql)
SqlDomain = cursor.description ####
DomainNum = len(SqlDomain)
SqlDomainName = [None]*DomainNum
for i in range(DomainNum):
SqlDomainName[i] = SqlDomain[i][0]
SqlResult = cursor.fetchall() ####
cursor.close()
result = [None]*2
result[0] = SqlDomainName
result[1] = SqlResult
return result
cursor.description 方法,列出table中每个字段的属性。返回一个二元元祖,((.., .., .., ..), (), (), )
cursor.fetchall 方法, 按字段顺序,列出每一行的值。返回一个二元元组,((.., .., .., ..), (), (), )