May-09-2019, 11:49 AM
(This post was last modified: May-09-2019, 11:50 AM by Daveinthebigcity.)
Hi,
I'm using mysql.connector to query my databases but I'm having trouble with the data type returned.
in my query result I'm just looking for a count of all the rows in a table and I'm using the query:
integer.
I can't seem to figure out the quick way to return the value just as an integer to shorten my code.
Any tips would be greatly appreciated.
Thanks
Dave
I'm using mysql.connector to query my databases but I'm having trouble with the data type returned.
in my query result I'm just looking for a count of all the rows in a table and I'm using the query:
getCount.execute("SELECT count(*) from tablename") countresult = getCount.fetchall()This does return the value I want i.e. 10, however the returned data is [(10,)] which I then have to string format and convert into an
integer.
I can't seem to figure out the quick way to return the value just as an integer to shorten my code.
Any tips would be greatly appreciated.
Thanks
Dave