StorageΒΆ
Unfortunately Tinydb only support JSONStorage
and
MemoryStorage
storage. because this, I add some popular
file types like storages.YAMLStorage
.
...
app.config["TINYDB_DATABASE_STORAGE"] = YAMLStorage
db = TinyDB(app)
...
of cource you can use your custom text-file storage method with storages.Storage
class:
from flask_tinydb.storages import Storage
class MyStorageMethod(Storage):
def read(self):
# do_something
def write(self):
# do_something
app.config["TINYDB_DATABASE_STORAGE"] = MyStorageMethod
db = TinyDB(app)
...