I do this from MyPhpAdmin it works perfectly. I want all columns it also works perfectly. But I just want the value inside one column, it does not work and I would like to know why. The result I get is a: tuple('year',) and I expect a date like (20200612). BTW: I don't know if this is useful but just in case, these methods are in different files. I just put them together so you can see. BTW2: If you think of better names or some mistakes feel free to correct me. I'm translating my project into English. Code:
def __set_year_to_student_subject(self,legajo:str,cod:str) -> None:
con,dao = self.__set_conecction_with_data_base()
year = dao.obtain_field_from_student_subject(legajo,cod,"year")
self.__subject.set_year_by_argument(year)
con.close()
def obtain_field_from_student_subject(self,legajo:str,code:str,field:str) -> tuple:
try:
cursor = self.__conecction.getcursor()
cursor.execute(f"SELECT '{field}' FROM {NAME_TABLE_SUB_ALU} WHERE idLegajo = \
'{legajo}' AND idcode = '{code}'")
data = cursor.fetchone()
cursor.close()
except Error as e:
raise ValueError(f"\n{strC('Error in mysql: Issue when trying to obtain data from
a field.',9)}\n{e}\n")
return data