Home>
sqlite3.OperationalError: unable to open database file
Corresponding source code
There are utils directory and model directory directly under the A directory, there is a file (test.py) containing the following code in the utils directory, and test.db is directly under the model directory.
# test.py
import sqlite3
import os.path
filepath = os.path.abspath ("../ model/test.db")
conn = sqlite3.connect (filepath)
What I tried
- I saw an article saying that it is better to use an absolute path instead of a relative path, so I passed the absolute path as above, but it does not change
- I saw an article that there are not enough permissions, so write permission
test.db
File,model
I changed both directories, but they didn't change
drwxrwxrwx @ 5 hogehoge staff 160 8 23 19:05 model
-rwxrwxrwx @ 1 hogehoge staff 21733376 3 27 2020 model/test.db
Supplementary information (FW/tool version, etc.)
- macOS 10.14.5
- Python 3.7.4
I get an error when I run test.py, but if anyone knows a solution, please let me know.
-
Answer # 1
-
Answer # 2
drwxrwxrwx @ 5 hogehoge staff 160 8 23 19:05 model
-rwxrwxrwx @ 1 hogehoge staff 21733376 3 27 2020 test.dbIt looks like test.db is outside the model directory, is that okay?
Related articles
- unable to get database values in python django
- python - the py file cannot be executed in the task scheduler 0x2 error
- python - categorical_crossentoropy error does not resolve
- python - how to resolve attribute error
- indent error doesn't go away, python
- python - an error occurs in the if statement program that compares the size of numbers
- python - sklearn, svm error
- python - error in image binarization using cv2adaptivethreshold function
- python - in raspberry pi, the error occurs only in the case of the automatic start program using systemd
- readcsv error in python
- error in import xlrd of python file from cakephp
- python - i want to display an image with pysimplegui, but an error occurs
- python - error when scraping with selenium and firefox
- [python] graphviz output format error
- python - i get an error when connecting to a voice channel with discordpy
- python 3x - best estimator: i get an error with no syntax, so please tell me what to do
- [python] i don't know how to solve the error
- python - unable to sort by dropdown selection column in jquery datatables
- python - an error has occurred in yolo v3
- python 3x - unable to execute python file
Trends
- python - you may need to restart the kernel to use updated packages error
- php - coincheck api authentication doesn't work
- php - i would like to introduce the coincheck api so that i can make payments with bitcoin on my ec site
- [php] i want to get account information using coincheck api
- the emulator process for avd pixel_2_api_29 was killed occurred when the android studio emulator was started, so i would like to
- javascript - how to check if an element exists in puppeteer
- dart - flutter: the instance member'stars' can't be accessed in an initializer error
- sh - 'apt-get' is not recognized as an internal or external command, operable program or batch file
- i want to call a child component method from a parent in vuejs
- python 3x - typeerror: 'method' object is not subscriptable
Since I didn't have permission from Python, I set test.db instead of model/test.db and it ran without error.
(For details, please see the column of "Addition/correction to questions, request for selection of best answer" commented by toast-uz)