0

Guys, I'm stumped here. Trying to retrieve a row from mysql using MySQLdb, I receive the number of matching rows found, not the data itself.

here's the code:

def getKbd(kb_num):
    query="SELECT kbd_name, kbd_data, kbd_ps FROM kbd_ WHERE kbd_number = %d " % kb_num
    a = c.execute(query)
    return a

print getKb(3)

the output is 1 (since one row matches. if I do sELECT * I get the number of rows in db.

here's the same query in mysql:

mysql> SELECT kbd_name, kbd_data, kbd_ps FROM kbd_ WHERE kbd_number = 3 ;
+-------------------------------------+------------------------------------------------------------------+-----------+
| kbd_name | kbd_data | kbd_passes |
+-------------------------------------+------------------------------------------------------------------+-----------+
| kbd name number 3 | kbd data for number 3 in here | 0 |
+-------------------------------------+------------------------------------------------------------------+-----------+
1 row in set (0.00 sec)


What I want to receive as output is a list or tuple with something like

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by DimaYasny
0

Thanks, I've just come up with the same. Strange how the cursor does everything standart sql syntax does, but doesn't return queries

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.