Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
177 views
in Technique[技术] by (71.8m points)

python - Getting an attribute error even though I have defined it in a class using self. function

I have tried several options posted online but none seem to work. I even tried assigning a separate variable to it and then using the delete command but even that doesn't work. Student_table has been defined in the class.

self.Student_table.delete(*self.Student_table.get_children()) - this is precisely where I'm getting an error

AttributeError: 'Student' object has no attribute 'Student_table'

this is the code

def search_data(self):
    mycon=mysql.connector.connect(host="localhost",user="X",passwd="X",database="test")
    cur=mycon.cursor()
    cur.execute("select * from student where '{}' = '{}'".format(self.search_by.get(),self.search_txt.get()))
    rows=cur.fetchall()
    self.Student_table.delete(*self.Student_table.get_children())
    for row in rows:
        self.Student_table.insert('',END,values=row)
   
        mycon.commit()
    mycon.close()  
question from:https://stackoverflow.com/questions/66058726/getting-an-attribute-error-even-though-i-have-defined-it-in-a-class-using-self

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...