I am currently having a few issues checking a database in python inside a loop.
Each time i am presented with the same value.
My goal is to check a table called seeTicketsEvents for empty event ids.
Then for each check another table called seeTicketsTickets for the name & data and then pass the id back to the first table.
when i query the second table with the function see_tickets_check_row(row) each time i get the same result.
`
def connect_to_db():
mydb = mysql.connector.connect(
host="localhost",
user="root",
password="root",
database="db",
unix_socket= "/Applications/MAMP/tmp/mysql/mysql.sock"
)
return mydb
`
`
def see_tickets_map_db():
mydb = connect_to_db()
with mydb.cursor() as mycursor:
mycursor.execute("SELECT * FROM `seeTicketsEvents` WHERE `ED_eventID` IS NULL")
for row in mycursor:
print(row)
see_tickets_check_row(row)
def see_tickets_check_row(data_row):
mydb = connect_to_db()
with mydb.cursor() as mycursor:
showdate = data_row[3]
showname = data_row[4]
print(showdate)
print(showname)
rowNew = []
mycursor = mydb.cursor()
mycursor.execute("SELECT * FROM `seeTicketsTickets` WHERE `showName` = showname AND `showDate` = showdate LIMIT 1")
for rowNew in mycursor:
#print(rowNew)
return rowNew[2]
`
I have tried putting the connections inside a with satment and also tried closing the connection all with no luck.
Any help would be hugely appreacated.