Skip to content

Create snapshots of database

James Kent edited this page Nov 22, 2023 · 1 revision
import json

from neurostore.resources.nested import nested_load
from neurostore.resources.data import StudysetsView
from neurostore.schemas import StudysetSnapshot

q = Studyset.query.filter_by(id='34zX9zSLDYXe')

q = q.options(nested_load(StudysetsView))

ns = q.one()

ns_dump = StudysetSnapshot().dump(ns)

with open("neurostore.json", "w+") as db:
    json.dump(ns_dump, db, default=str)