3

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

Thanks.

Bry6n
2,0391 gold badge13 silver badges20 bronze badges
asked Mar 16, 2011 at 6:14
1
  • I think, that is because you are using \n within that string which is geting interpreted as newline. Use raw-string and see my answer below. Commented Mar 16, 2011 at 6:24

2 Answers 2

1

\ is the escape character in python strings. You have to use double backslashes:

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

Or like Senthil said, use raw strings:

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

For more information, check the Python doc about string literals.

answered Mar 16, 2011 at 7:45
Sign up to request clarification or add additional context in comments.

Comments

1

Where is your python process running from? Try to point to the absolute path of the file. And when pointing to path use raw string r'c:\\mypath\data\notktalar.sub'

answered Mar 16, 2011 at 6:23

1 Comment

Thanks. You solved my problem. Actually I dont need to specify the full path. r'data\noktalar.sdb' is enough.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.