1
votes

I have a flask application that works file until I try and assign a full path to the location of my sqlite3 db. I will need to have a full path to allow the user to switch db's if need.

I have developed the app with the db's in the same location as the .py files now I have moved the db and it can't find the tables.

python code: I originally tried "+" before os.path.join.

BasePath = "/storage/resources/dbase/dbSTR/SS1/"
...
 tfile = os.path.join(BasePath,"dbSTR.db")
    print(tfile)
    conn = sqlite3.connect(tfile)

the tfile variable has : /storage/resources/dbase/dbSTR/SS1/dbSTR.db

The error is can't find strlocmotif table. i.e. db is empty.

Command line from where the .py file is stored:

sqlite3 /storage/resources/dbase/dbSTR/SS1/dbSTR.db

SQLite version 3.25.2 2018-09-25 19:08:10 Enter ".help" for usage hints. sqlite> .tables COHORTS directives hg19 newfeat2 strlocmotif
attribs duplicates meta relations
autoincrements features newattrib strloc

2

2 Answers

1
votes

It ended up working with the + syntax. I miss typed something. Thank You for your help!

0
votes

What is the output of the print statement? I think the last forward slash on the end of BasePath might be confusing os.path.join() if it doesn't expect it. You could try just manually concatenating the paths as strings and see if that works.