>
> I tried the path '/myapplicationname/databases/test.sqlite', the sort 
> of path that can be used for images. But I get the following error. 
>
> <class 'sqlite3.OperationalError'> unable to open database file 
>
> What is request.folder? How do I find it?
>

The request object is available in the web2py environment on every request 
-- request.folder stores the filesystem path to the current application's 
folder. You can access it anywhere in your app code. See 
http://web2py.com/books/default/chapter/29/4#request. To construct a full 
path, you should use os.path.join:

import os
sqlite_file_path = os.path.join(request.folder, 'databases', 'test.sqlite')

That should produce something like 
'/path/to/web2py/applications/yourapplication/databases/test.sqlite' (of 
course, it will vary by OS -- on Windows it would start with C: and use \'s 
instead of /'s).

Anthony

Reply via email to