# peewee.OperationalError: unable to open database file

**URL:** <https://support.prodi.gy/t/peewee-operationalerror-unable-to-open-database-file/1791>\
**Category:** Uncategorized\
**Tags:** usage, database, solved\
**Created:** [July 16, 2019, 4:49pm UTC](https://support.prodi.gy/t/peewee-operationalerror-unable-to-open-database-file/1791 "2019-07-16T16:49:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![weijia\_sun](https://avatars.discourse-cdn.com/v4/letter/w/edb3f5/32.png) [@weijia\_sun](https://support.prodi.gy/u/weijia_sun)\
**Post date:** [July 16, 2019, 4:49pm UTC](https://support.prodi.gy/t/peewee-operationalerror-unable-to-open-database-file/1791/1 "2019-07-16T16:49:08Z")

</div>

the whole error info with the command “python3 -m prodigy dataset my\_dataset ‘a data set’” is as following:

===========================================================

f018984afbb1:prodigy cdu794$ python3 -m prodigy dataset my\_set “a data set”  
Traceback (most recent call last):  
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/peewee.py”, line 3768, in \_create\_connection  
return self.\_connect(self.database, \*\*self.connect\_kwargs)  
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/peewee.py”, line 4023, in \_connect  
conn = sqlite3.connect(database, \*\*kwargs)  
sqlite3.OperationalError: unable to open database file

During handling of the above exception, another exception occurred:

Traceback (most recent call last):  
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/peewee.py”, line 3828, in execute\_sql  
cursor = self.get\_cursor()  
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/peewee.py”, line 3774, in get\_cursor  
return self.get\_conn().cursor()  
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/peewee.py”, line 3763, in get\_conn  
self.connect()  
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/peewee.py”, line 3738, in connect  
self.\_local.conn = self.\_create\_connection()  
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/peewee.py”, line 3768, in \_create\_connection  
return self.\_connect(self.database, \*\*self.connect\_kwargs)  
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/peewee.py”, line 3656, in **exit**  
reraise(new\_type, new\_type(\*exc\_args), traceback)  
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/peewee.py”, line 135, in reraise  
raise value.with\_traceback(tb)  
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/peewee.py”, line 3768, in \_create\_connection  
return self.\_connect(self.database, \*\*self.connect\_kwargs)  
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/peewee.py”, line 4023, in \_connect  
conn = sqlite3.connect(database, \*\*kwargs)  
peewee.OperationalError: unable to open database file

During handling of the above exception, another exception occurred:

Traceback (most recent call last):  
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py”, line 193, in \_run\_module\_as\_main  
“ **main** ”, mod\_spec)  
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py”, line 85, in \_run\_code  
exec(code, run\_globals)  
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/prodigy/ **main**.py”, line 372, in   
plac.call(commands[command], arglist=args, eager=False)  
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/plac\_core.py”, line 328, in call  
cmd, result = parser.consume(arglist)  
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/plac\_core.py”, line 207, in consume  
return cmd, self.func(\*(args + varargs + extraopts), \*\*kwargs)  
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/prodigy/ **main**.py”, line 46, in dataset  
if set\_id in DB:  
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/prodigy/components/db.py”, line 177, in **contains**  
has\_ds = bool(Dataset.get(Dataset.name == name))  
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/peewee.py”, line 4988, in get  
return sq.get()  
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/peewee.py”, line 3220, in get  
return next(clone.execute())  
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/peewee.py”, line 3274, in execute  
self.\_qr = ResultWrapper(model\_class, self.\_execute(), query\_meta)  
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/peewee.py”, line 2939, in \_execute  
return self.database.execute\_sql(sql, params, self.require\_commit)  
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/peewee.py”, line 3837, in execute\_sql  
self.commit()  
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/peewee.py”, line 3656, in **exit**  
reraise(new\_type, new\_type(\*exc\_args), traceback)  
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/peewee.py”, line 135, in reraise  
raise value.with\_traceback(tb)  
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/peewee.py”, line 3828, in execute\_sql  
cursor = self.get\_cursor()  
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/peewee.py”, line 3774, in get\_cursor  
return self.get\_conn().cursor()  
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/peewee.py”, line 3763, in get\_conn  
self.connect()  
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/peewee.py”, line 3738, in connect  
self.\_local.conn = self.\_create\_connection()  
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/peewee.py”, line 3768, in \_create\_connection  
return self.\_connect(self.database, \*\*self.connect\_kwargs)  
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/peewee.py”, line 3656, in **exit**  
reraise(new\_type, new\_type(\*exc\_args), traceback)  
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/peewee.py”, line 135, in reraise  
raise value.with\_traceback(tb)  
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/peewee.py”, line 3768, in \_create\_connection  
return self.\_connect(self.database, \*\*self.connect\_kwargs)  
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/peewee.py”, line 4023, in \_connect  
conn = sqlite3.connect(database, \*\*kwargs)  
peewee.OperationalError: unable to open database file

---

<div class="post-metadata">

**Author:** ![weijia\_sun](https://avatars.discourse-cdn.com/v4/letter/w/edb3f5/32.png) [@weijia\_sun](https://support.prodi.gy/u/weijia_sun)\
**Post date:** [July 16, 2019, 6:20pm UTC](https://support.prodi.gy/t/peewee-operationalerror-unable-to-open-database-file/1791/2 "2019-07-16T18:20:56Z")

</div>

So how can i modify my prodigy.json? i just copy paste from the help docs as following without any modification.

======================================================

```python
{
    "theme": "basic",
    "custom_theme": {},
    "batch_size": 10,
    "port": 8080,
    "host": "localhost",
    "cors": true,
    "db": "sqlite",
    "db_settings": {},
    "api_keys": {},
    "validate": true,
    "auto_create": true,
    "auto_exclude_current": true,
    "instant_submit": false,
    "feed_overlap": true,
    "show_stats": false,
    "hide_meta": false,
    "show_flag": false,
    "instructions": false,
    "swipe": false,
    "split_sents_threshold": false,
    "diff_style": "words",
    "html_template": false,
    "global_css": null,
    "javascript": null,
    "writing_dir": "ltr",
    "hide_true_newline_tokens": false,
    "ner_manual_require_click": false,
    "ner_manual_label_style": "list",
    "choice_style": "single",
    "choice_auto_accept": false,
    "darken_image": 0,
    "show_bounding_box_center": false,
    "preview_bounding_boxes": false,
    "shade_bounding_boxes": false
}

```

---

<div class="post-metadata">

**Author:** ![ines](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ines/32/3_2.png) [@ines](https://support.prodi.gy/u/ines)\
**Post date:** [July 16, 2019, 6:40pm UTC](https://support.prodi.gy/t/peewee-operationalerror-unable-to-open-database-file/1791/3 "2019-07-16T18:40:19Z")

</div>

@weijia_sun Ah, sorry – I was replying to the first tweet in [the thread](https://support.prodi.gy/t/dataset-creation-unexpected-character-in-found-when-decoding-object-value/1790). I didn’t see that you had also posted something else in the meantime. Your error looks quite different and most likely isn’t related, so I moved it to a new topic.

What’s going on here is that Prodigy can’t create a new SQLite database and/or open the database file. This is likely not a problem in Prodigy itself. Here are some tips to debug this:

- Double-check that SQLite is installed and available. It should be included with Python, but depending on your build and platform, maybe it’s not.
- Double-check that a `.prodigy` directory was created in your user home directory and is writable (that’s what should happen by default). Alternatively, you can use the `PRODIGY_HOME` environment variable to point it to a writable directory Prodigy can create the `prodigy.json` and SQLite database file in.

---

<div class="post-metadata">

**Author:** ![weijia\_sun](https://avatars.discourse-cdn.com/v4/letter/w/edb3f5/32.png) [@weijia\_sun](https://support.prodi.gy/u/weijia_sun)\
**Post date:** [July 17, 2019, 5:21pm UTC](https://support.prodi.gy/t/peewee-operationalerror-unable-to-open-database-file/1791/4 "2019-07-17T17:21:15Z")

</div>

the issue has been fixed up.  
i use “sudo” to execute the dataset creating command as following:  
$sudo python3 -m prodigy dataset my\_dataset “a new dataset”
