How can I reach one of results from database in Python
I'm trying to get some infos fro database in Python. Im new in it and I,
unfortunatelly, wasted a lot of time for that. I expect that my problem is
really simple. I have sth like that to fetch data:
def FetchResults(con, sql):
cur = con.cursor()
cur.execute(sql)
return cur.fetchall()
_con = ConnectDB(config.host, config.user, config.passwd, config.db)
bbb = FetchResults(_con,"SELECT sth FROM sth")
for row in bbb:
if row[0] != None:
print row[0]
and my results are sth like that:
{"sth1":"aaaa","sth2":"qwe"}
{"sth1":"bbbb","sth2":"qwe"}
How can I reach for example "sth2" now
Thanks
No comments:
Post a Comment