Problem Concatenate Str To Database For Recall The Two Id In Button Insert
I created these two functions, adding various + in curson.execute: def getIDCampionato(nome_campionato): cursor.execute('SELECT ID_Campionato FROM ARCHIVIO_Campionati WHERE Nom
Solution 1:
As per the first error you have displayed, make sure you are not passing a list to these functions:
[ nome_campionato single string ] *not part of code
[ id_campionato & giornata single integer values ] *not part of code
import traceback
defgetIDCampionato(nome_campionato):
ifisinstance(nome_campionato,str):
try:
query1 = "SELECT ID_Campionato FROM ARCHIVIO_Campionati WHERE Nome_Campionato = ?;"
cursor.execute(query1, (nome_campionato,)) # if error, try passing these params in a list like -> [nome_campionato]
result=[row[0] for row in cursor]
return result
except:
print('Error generated for ->', nome_campionato, '\n')
print(traceback.format_exc())
else:
print('This needs to be a string ->', nome_campionato)
return0# as per the error generated this function should work fine, try it standalonedefgetIDGiornata(id_campionato, giornata):
ifisinstance(id_campionato, int) andisinstance(giornata, int):
query2 = "SELECT Numero_Giornata FROM ARCHIVIO_Giornate WHERE Relaz_Campionato = ? and Numero_Giornata = ?;"
cursor.execute(query2, (id_campionato, giornata,)) # [id_campionato, giornata]
result=[row[0] for row in cursor]
return result
else:
print('Both need to be integer values -> id_campionato = ', id_campionato, ' || giornata = ', giornata)
return0
Try the updated functions above.
The reason it is not printing is that we were confirming the datatype directly, so that seems to be correct, the issue is something else! still to get an idea I have added some more print statements.
I have added commas as suggested by error resolution
try calling the function getIDGiornata(id_campionato, giornata) separately to see if it works, if not add the try-except block as the previous function and post an image.
Post a Comment for "Problem Concatenate Str To Database For Recall The Two Id In Button Insert"