I am working on database connectivity in Python 3.4. There are two columns in my database.
Below is the query which gives me all the data from two columns in shown f
As the output you given [('F:\\test1.py', '12345abc'), ('F:\\test2.py', 'avcr123')]
for i, row in data:
print(i) # i is column1's value
print(row)# row is column's value
So you don't need row[i] or row[j], that was wrong, in that each step of that iteration
for i, row in data
is the same as i, row = ('abc', 'def')
it set abc
to variable i
and 'def' to row
BTW ,I don't know what database you use, if you use Mysql
and python driverMySQL Connector
, you can checkout this guide to fetch mysql result as dictionary
you can get a dict in iteration, and the keys is your table fields' name. I think this method is convenient more.