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 方法, 按字段顺序,列出每一行的值。返回一个二元元组,
((.., .., .., ..), (), (), )




相关文章:

  • 2021-12-11
  • 2022-12-23
  • 2022-12-23
  • 2021-07-30
  • 2021-08-25
猜你喜欢
  • 2021-06-04
  • 2022-01-03
  • 2022-12-23
  • 2021-06-01
  • 2022-12-23
  • 2021-11-18
  • 2021-06-17
相关资源
相似解决方案