I am using sqlite3 and python for a new website I am creating. The problem is, the "files_storage.db" file I am trying to create will not appear in any Windows 10 Folder Window, PyCharm's Directory View, nor will it appear via the command line interface.
The catch to this is, if I execute my python script multiple times, I get an error that states the database file already exists... So this file is somewhere, I guess it is a game of cat and mouse to find it.
I have ran into this problem before, but I have ALWAYS been able to find the file via the command line. Usually, I wouldn't both yall with such a question but, this is really irking me and I am going to run into serious issues when it comes time to put this baby on a server. :(
thanks in advance, and here's some screenshots I suppose.

- 85
- 2
- 10
-
You are using a relative file path. Try to open it with an absolute path (starting with drive letter). – Michael Butscher Dec 27 '17 at 01:03
-
Wow, that didn't initally make a change in the IDE... but it appeared in the command line. Once I printed to the contents of the folder in the command line, it then mysteriously appeared in the IDE... Any info on how this changed anything? The relative/absolute paths shouldn't change much. Perhaps it has to do with processor caching? I am just stabbing wildly and making guesses but, I'd love to hear your answer if you have one. Btw thank you very much, that was very quick. – Michael Beyer Dec 27 '17 at 01:09
-
2BTW if you want to make a formal answer so I can mark you as the best answer, that'd be great so we can help others who are searching google/stack overflow. – Michael Beyer Dec 27 '17 at 01:09
-
Thank you, I have made a slightly more verbose answer. – Michael Butscher Dec 27 '17 at 01:13
-
In the future, please do *not* post code as a picture. It's very hard to read. – Roland Smith Dec 27 '17 at 01:23
-
@RolandSmith I felt that this question was not about code directly but, about the results of the code but, I shall remember that. I felt like this post would've seemed incomplete and lacking info without screenshots because, their was no point to posting my source code as I knew I had made no errors in implementation of the script. Would it have been appropriate to just post the question with the picture of the command line? I had an urge to give some direct information concerning the error. – Michael Beyer Dec 27 '17 at 02:42
-
@MichaelBeyer Could you have copied the code, the results of the run window and the powershell window, and put them in the question? – Roland Smith Dec 27 '17 at 10:57
-
@RolandSmith good point, i'll do that. – Michael Beyer Dec 27 '17 at 18:26
3 Answers
You are using a relative file path.
Relative paths are converted to absolute ones by something like os.path.join(os.getcwd(), <relative path>)
. So they depend on the current working directory of the process.
Try to open it with an absolute path (starting with drive letter) to avoid any ambiguities.

- 10,028
- 4
- 24
- 25
If you use just a filename without a path, the file will be saved in whatever the current working directory of the Python interpreter is.
To see where the current working directory is, add the following code to the beginning of your program:
import os
print(os.getcwd())
You should then see the working directory in the output.
There is a setting for the current working directory in your IDE somewhere. See e.g. the answers to this question.

- 42,427
- 3
- 64
- 94
You can also do something like:
import os
path = os.path.expanduser("~") + '/Documents'
print(path)
This will allow you to access the directories for the current user. For me, this prints:
'/Users/thomasweeks/Documents'

- 85
- 8