Fonksiyonlar içine aldım. Kimlik değişkenini SQLUpdate fonksiyonunun içine gönderiyorum fakat SendWP kolonuna E harfini yazdıramıyorum..
def KimlikSaat():
global Kimlik
try:
connection = pymysql.connect(host='192.168.1.1',user='root',password='abc',db='database',charset='utf8mb4',cursorclass=pymysql.cursors.DictCursor)
with connection.cursor() as cursor:
sql = "select Kimlik,Saat FROM BildirilenHatalar where Hata like 'NUMUNE YOK' and SendWP not like 'E' order by Kimlik asc limit 1"
cursor.execute(sql)
for row in cursor.fetchall():
Kimlik = str(row["Kimlik"])
Saat = str(row["Saat"])
print (Kimlik)
print (Saat)
return (Kimlik)
finally:
cursor.close()
connection.close()
def SQLUpdate():
try:
connection = pymysql.connect(host='192.168.1.1',user='root',password='abc',db='database',charset='utf8mb4',cursorclass=pymysql.cursors.DictCursor)
with connection.cursor() as cursor:
update = """ update BildirilenHatalar set SendWP = %s where Kimlik = %s """
cursor.execute(update,'E',Kimlik)
connection.commit()
print ("Veri güncellendi")
except TypeError:
print ("Hata oluştu!")
finally:
cursor.close()
connection.close()
KimlikSaat()
SQLUpdate()