Answer the question
In order to leave comments, you need to log in
Why doesn't Qfiledialog close after clicking ok?
def openFileNameD(self):
fileName=QtWidgets.QFileDialog.getOpenFileName()[0]
return fileName
# функция для проверки соединения с бд и в ней будет вызов функции для выбора файла бд
def cheak_conection_with_db(self, adress_file, adress_of_data_base,rewritenum):
try:
dburi = 'file:{}?mode=rw'.format(pathname2url(adress_of_data_base))
conn = sqlite3.connect(dburi, uri=True)
print('yes')
return adress_of_data_base
except sqlite3.OperationalError:
print('no')
#=r'E:\Myproject\New_Hotel_Interface\OB_DB.sqlite'
a =self.openFileNameD()
if rewritenum==0:
with open(adress_file, 'w'):
pass
file= open(adress_file,'w')
file.write(a[0])
file.close()
return a[0]
else:
return a[0]
#функция которая отдает адрес бд из файла на проверку конекта в def cheak_conection_with_db и после в миксер запросов
# adress_file - адрес текстового файла , adress_of_data_base - адрес базы данных ,rewritenum - переменная для перезаписи адреса в бд
def adressmaker(self):
adress_file=os.path.abspath('form.py')
adress_file=adress_file.replace('form.py','')
adress_file=adress_file+'myadress.txt'
adress_of_data_base=''
if os.path.isfile(adress_file) is True:
file=open(adress_file,'r')
adress_of_data_base=file.readline()
file.close()
##################################################
if not adress_of_data_base:
adress_of_data_base=self.openFileNameD()
##################################################
return self.cheak_conection_with_db(adress_file,adress_of_data_base,0)
else:
file=open(adress_file,'w')
adress_of_data_base=adress_file.replace('myadress.txt','OB_DB.sqlite')
adress_of_data_base=self.cheak_conection_with_db(adress_file,adress_of_data_base,1)
file.write(adress_of_data_base)
file.close()
return adress_of_data_base
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question