I connect to the mysql database through the mysql connector and run a simple query to pull out a list of identifiers. I need to iterate over this list and pass them to another code. For some reason, I get a list of tuples. Is this expected behavior? If not, what am I doing wrong? Here is a snippet of my code:
import mysql.connector
conn = mysql.connector.connect(host='127.0.0.1', database='t', user='r', password='pwd')
cursor = conn.cursor()
query = ( "select id from T where updated < '%s'" % (run_date) )
cursor.execute(query)
for row in cursor:
print (row)
cursor.close()
I get the following response (from the INT field to d / b):
(Decimal('991837'),)
(Decimal('991838'),)
(Decimal('991839'),)
(Decimal('991871'),)
(Decimal('991879'),)
(Decimal('991899'),)
(Decimal('992051'),)
(Decimal('992299'),)
(Decimal('992309'),)
source
share