home folder "~" not recognized in paths in prodigy.json

When I use the ~ character in the "path" entry to set a path for the database I receive the following error

peewee.OperationalError: unable to open database file

This is automatically fixed if I use the complete path.

prodigy.json

{
"db": "sqlite",
"db_settings": {
    "sqlite": {
      "name": "prodigy.db",
      "path": "~/.prodigy"
    }
  }
}

Hi! I'm not sure I'd classify this a bug – it seems to be how peewee/sqlite handle their database paths? The path plus name is passed directly to the database handler and Prodigy doesn't make any modifications to that path. Since ~ isn't a valid path, it ends up calling something like sqlite3.connect("~/.prodigy/prodigy.db"), which causes the error you're seeing.

I guess Prodigy could explicitly call Path.expanduser on the path here before passing it on, which would resolve the ~ to the home directory. This lets you avoid hard-coding the user in the path, e.g. if you're deploying Prodigy on different machines.

That said, the database path defaults to the PRODIGY_HOME directory, which can be set via an environment variable. So that'd probably be a better solution for deployment etc.