Python Forum
Reading in MYSQL data as integer type
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Reading in MYSQL data as integer type
#1
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:

 
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
Reply


Messages In This Thread
Reading in MYSQL data as integer type - by Daveinthebigcity - May-09-2019, 11:49 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Help with writing monitored data to mysql upon change of one particular variable donottrackmymetadata 3 394 Apr-18-2024, 09:55 PM
Last Post: deanhystad
  Mysql and mysql.connector error lostintime 2 766 Oct-03-2023, 10:25 PM
Last Post: lostintime
  reading a table which is of type string saisankalpj 2 1,004 Dec-03-2022, 11:19 AM
Last Post: saisankalpj
  Reading All The RAW Data Inside a PDF NBAComputerMan 4 1,446 Nov-30-2022, 10:54 PM
Last Post: Larz60+
  Reading Data from JSON tpolim008 2 1,149 Sep-27-2022, 06:34 PM
Last Post: Larz60+
  Mysql error message: Lost connection to MySQL server during query tomtom 6 16,463 Feb-09-2022, 09:55 AM
Last Post: ibreeden
  Help reading data from serial RS485 korenron 8 14,361 Nov-14-2021, 06:49 AM
Last Post: korenron
  Help with WebSocket reading data from anoter function korenron 0 1,366 Sep-19-2021, 11:08 AM
Last Post: korenron
  Fastest Way of Writing/Reading Data JamesA 1 2,244 Jul-27-2021, 03:52 PM
Last Post: Larz60+
  SaltStack: MySQL returner save less data into Database table columns xtc14 2 2,227 Jul-02-2021, 02:19 PM
Last Post: xtc14

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020