o akka
o akka

Reputation: 81

i want to insert a json file in RavenDb with python

I am looking for a method, on how can I insert values as JSON format in RavenDB with python.

code:

cert = {'pfx': '...', 'password': '...'}
    document_store = document_store.DocumentStore(["link DB"], "name DB", certificate=cert)
    doc = {"id":123, "name": "BLA BLA BLA"}
    id = "TiktokPosts"
    document_store.initialize()
    with document_store.open_session() as session:
        session.store(doc, id)
        session.save_changes()

Upvotes: 2

Views: 155

Answers (1)

Ayende Rahien
Ayende Rahien

Reputation: 22956

Assuming you want to read a JSON file and put that in RavenDB, you can use:

    import json
     
    f = open('data.json')
    data = json.load(f)
    
    with document_store.open_session() as session:
            session.store(data , "my-doc-id")
            session.save_changes()

Upvotes: 1

Related Questions