Вопрос

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
Это было полезно?

Решение

    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
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top