3个回答
展开全部
def query(self, sql):
connect = self.connect()
cur = connect.cursor()
cur.execute(sql)
index = cur.description
result = []
for res in cur.fetchall():
row = {}
for i in range(len(index)-1):
row[index[i][0]] = res[i]
result.append(row)
connect.close()
return result
这个方法返回查询结果就是带字段名的{‘字段名’:‘值’}
connect = self.connect()
cur = connect.cursor()
cur.execute(sql)
index = cur.description
result = []
for res in cur.fetchall():
row = {}
for i in range(len(index)-1):
row[index[i][0]] = res[i]
result.append(row)
connect.close()
return result
这个方法返回查询结果就是带字段名的{‘字段名’:‘值’}
2011-07-25
展开全部
表名和列明一般都存储在系统表里面,只要你找到那个系统表.SQL Server 表名存储在sysobjects中,而列名存储在syscolumns中,从这两张表中能查到某个表的列名
参考资料: http://www.baigreen.com/cate/python
展开全部
csvTitle = ""
view_datas = db.GqlQuery("select * from OrderData where order_number = :1",orderKey)
view_data = view_datas[0]
data1 = view_data._entity
dataAll = str(data1).split(',')
for datas in dataAll:
data = str(datas).split(':')
if(len(data) > 1):
setTitle = str(data[0])
setTitle = setTitle.replace("u'", "'")
setTitle = setTitle.replace("'", '')
setTitle = setTitle.replace("{", '')
csvTitle += str(setTitle + ",")
writer.writerow([csvTitle])
self.response.out.write(response.content)
肯定好用!
view_datas = db.GqlQuery("select * from OrderData where order_number = :1",orderKey)
view_data = view_datas[0]
data1 = view_data._entity
dataAll = str(data1).split(',')
for datas in dataAll:
data = str(datas).split(':')
if(len(data) > 1):
setTitle = str(data[0])
setTitle = setTitle.replace("u'", "'")
setTitle = setTitle.replace("'", '')
setTitle = setTitle.replace("{", '')
csvTitle += str(setTitle + ",")
writer.writerow([csvTitle])
self.response.out.write(response.content)
肯定好用!
参考资料: 原创
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询