[Tutor] Cannot open SQLite database
Alan Gauld
alan.gauld at btinternet.com
Wed Feb 24 10:09:27 CET 2010
"Timo" <timomlists at gmail.com> wrote
> OperationalError: unable to open database file
Does the file actually exist where you say it does?
> # This will return: C:\Documents and Settings\user\Application Data\myapp
> PREFDIR = os.path.join(os.environ['APPDATA'], 'myapp')
Do you check that APPDATA is actually set?
> # Connect to the database
> def db_connect():
> conn = sqlite3.connect(os.path.join(PREFDIR, 'myapp.db')) # This
Do you do an is file exists check before trrying to use it?
And that the permissions on both directory and file are set up correctly?
That would be my guess at likely errors.
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
More information about the Tutor
mailing list