Python database error

When I put my database file (which is .sdb) in a directory and try to access it from this directory, I get an error message. The error reads "cannot open the database file." For example, let my .sdb file be in the "data" directory, and I use the command "con = lite.connect ('data \ noktalar.sdb"), this error occurs. Why is this so?

Thank.

+3
source share
2 answers

\is an escape character in python strings. You should use double backslash:

con = lite.connect('data\\noktalar.sdb')

Or, as Sentil said, use raw strings:

con = lite.connect(r'data\noktalar.sdb')

Python .

+1

python-? . r'c:\\mypath\data\notktalar.sub'

+1

All Articles