SQLite User Forum

SQLite DB Not working (”No database file opened”)
Login

SQLite DB Not working ("No database file opened")

(1) By anonymous on 2022-10-15 22:01:12 [link] [source]

Hi, im learning to code in python and im with the BBDD part of the course that im doing. So, the two first days that i was making code with database management i was able to open the table that i made with SQlite DB and it was working as usual.

I made another virtual PC with VirtualBox and trasladed all the codes and databases files there, and now the app just doesn´t work

Every time that i try to open a database it says "No database file opened" with no reason, it happens with the old files and the new ones that i make at this moment.

Can someone help me with this? I´ll be re-installing it to see if that fixes the problem, anyway thanks for reading.

(2.1) By Chris Locke (chrisjlocke1) on 2022-10-16 12:52:28 edited from 2.0 in reply to 1 [source]

Part 1 is identifying what file the code is trying to open. Does the code open an existing database, or make one from scratch?

If making one, does the location the code is writing to exist?

If you've moved computers, the common mistake is hard coding in a desktop location - c:\users\user1\desktop, when that user doesn't exist on computer #2.

(3) By Aask (AAsk1902) on 2022-10-16 08:51:29 in reply to 2.0 [link] [source]

MarkUp ate the backslashes; for clarity:

c:\users\user1\desktop

(5) By Chris Locke (chrisjlocke1) on 2022-10-16 12:52:56 in reply to 3 [link] [source]

Whoops! Didn't re-read after posting. Thanks!

(4) By Simon Slavin (slavin) on 2022-10-16 11:02:47 in reply to 1 [link] [source]

Try using python code to open the same file just as a file. Ignore the fact you want to use a database and pretend it's a text or binary file of the same name in the same location. Open it, read the first byte, then close it again.

Does that work ? If not, why not ?