Search code examples
pythonruntime-errortinydb

How to handle "TypeError: __init__() missing 1 required positional argument: 'path'"


I want to set up a new tinyDB object in Python 3, but TinyDB() gives me this error

Traceback (most recent call last):
  File "C:/Users/Utente/Documents/CodingStuff/AlgManager/AlgManager.py", line 4, in <module>
    db = tdb.TinyDB()
  File "C:\Users\Utente\PycharmProjects\prova\venv\lib\site-packages\tinydb\database.py", line 159, in __init__
    self._storage = storage(*args, **kwargs)
TypeError: __init__() missing 1 required positional argument: 'path'

I guess it's something about installation, because the code I wrote is really only

import tinydb as tdb

db = tdb.TinyDB()

I installed TinyDB with pip. What can I do?


Solution

  • No matter what python version you use TinyDB has a required parameter "path to db" when you create the instance.

    Something like this:

    import tinydb as tdb
    db = tdb.TinyDB('path/to/db.json')