есть класс
class base:
def __init__( self ):
self.connection = None
self.main_database_name=None
self.sqlite_connection=None
self.cursor=None
self.sqlite_create_table_query=None
self.query=None
self.parametr=None
def connect(self,main_database_name):
self.main_database_name=main_database_name
self.sqlite_connection = sqlite3.connect(main_database_name)
self.cursor = self.sqlite_connection.cursor()
return main_database_name
def close(self):
if (sqlite_connection):
self.sqlite_connection.close()
print("закрыто")
def create_table(self,sqlite_create_table_query):
self.sqlite_create_table_query =sqlite_create_table_query
self.cursor.execute(sqlite_create_table_query)
self.sqlite_connection.commit()
return print("сохранено")
я произвожу запрос к этому классу
def connect():
name_DB = filedialog.askopenfilename(filetypes=(("Database", ".db"),))
mdb=base()
mdb.connect(name_DB)
return name_DB
def download():
# подключение к бд
name_DB=connect()
print(name_DB)
db=base()
name_db = os.path.basename(name_DB)
#-------------------------------------
sqlite_create_table_query='''CREATE TABLE session (id INTEGER PRIMARY KEY ,ip_src TEXT ,ip_dst TEXT ,sport TEXT , dport TEXT ,request TEXT ,response TEXT );'''
db.create_table(sqlite_create_table_query)
и вылетает ошибка
Traceback (most recent call last):
File "D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\tkinter\__init__.py", line 1705, in __call__
return self.func(*args)
File "D:\Work\Program\SniffPcap\SniffPcap\SniffPcap.py", line 126, in download
db.create_table(sqlite_create_table_query)
File "D:\Work\Program\SniffPcap\SniffPcap\SniffPcap.py", line 53, in create_table
self.cursor.execute(sqlite_create_table_query)
AttributeError: 'NoneType' object has no attribute 'execute'