0

I have option menu widget:

optionTuple = ("filename1", "filename2", "filename3")

filename1, filename2, filename3 are also names of files in directory


then I have button which inter alia gets selected option value:

def btnConvertClick(self):
    filename = '"'+ optionMenuWidget.cget('text')+'"'


then I try to open [sqlite3]database file [filename1 or filename2 or filename3] according to selected option

selected_file = filename
db = sqlite3.connect(selected_file)

but I get error:

<class 'sqlite3.OperationalError'>: unable to open database file

I have no problem with:

db = sqlite3.connect("filename1")

Is it possible to put string from function [as above] as filename argument?

1 Answer 1

2

Try setting the filename without the quotes:

filename = optionMenuWidget.cget
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.