I am trying to get a single cell of values from MySQLdb, in Python. Here’s my code:
fname = c.execute("""SELECT fname from employees WHERE user = %s;""", (useruname))
However what I get is “1L”, which is not what I want – fname should contain a string, not a long integer.
Why would it do this?
The method
execute“returns long integer rows affected, if any”.To get the value of fname, you need to fetch the results using for example
fetchallorfetchone: