Feb-04-2019, 07:09 PM
When I run the following code it issues an error message. Can't figure it out.
Traceback (most recent call last):
File "//MYBOOKLIVE/Public/Code/New/a_test.py", line 23, in <module>
app = Application(master=root)
File "//MYBOOKLIVE/Public/Code/New/a_test.py", line 6, in __init__
conn = self.create_connection()
TypeError: create_connection() takes 0 positional arguments but 1 was given
I have specified zero arguments yet it still gets the error message. Please help.
from tkinter import * class Application(Frame): def __init__(self, master=None): Frame.__init__(self, master) conn = self.create_connection() def create_connection(): """ create a database connection to the SQLite database specified by the db_file :param db_file: database file :return: Connection object or None """ try: filename = "\\\\MYBOOKLIVE\\Public\\Databases\\DM_Earnings_2019.db" conn = sqlite3.connect(filename) except Error as e: print(e) finally: return conn root = Tk() app = Application(master=root) app.pack(side=TOP, fill=BOTH, expand=True) root.mainloop()I get the following message.......
Traceback (most recent call last):
File "//MYBOOKLIVE/Public/Code/New/a_test.py", line 23, in <module>
app = Application(master=root)
File "//MYBOOKLIVE/Public/Code/New/a_test.py", line 6, in __init__
conn = self.create_connection()
TypeError: create_connection() takes 0 positional arguments but 1 was given
I have specified zero arguments yet it still gets the error message. Please help.