import _mysql
db=_mysql.connect("localhost","sundar","","test")
db.query("select username from auth_user")
result = db.store_result()
r=""
while True:
record = result.fetch_row()
if not record: break
elif record is None:break
else:r+= record[0][0]
print r
Python : append mysql results
-
09-07-2023 - |
Question
Here's my script.
import _mysql
db=_mysql.connect("localhost","01","","z")
db.query("select id from a limit 2")
result = db.store_result()
while True:
record = result.fetch_row()
if not record: break
print record
(execution & the outcome) is :
[root@ooo ~]# python a.py
(('1',),)
(('2',),)
[root@ooo ~]#
the results are correct but i would like it append all the results and simply print ( based on above output )
12
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow