File size: 821 Bytes
1de1fd2
022601f
 
 
 
1de1fd2
 
 
 
022601f
 
 
1de1fd2
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from pymongo import MongoClient
import datetime

class ResponseDb:
    def __init__(self):
        # Set up the connection
        self.client = MongoClient(f"mongodb+srv://{mongodb_username}:{mongodb_pw}@{mongodb_cluster_url}/?retryWrites=true&w=majority")
        self.db = self.client['vqa-game']
        self.collection = self.db['vqa-game']

    def add(self, dialogue_id, task_id, turn, question, response):
        curr_datetime = datetime.datetime.now()
        document = {"dialogue_id":dialogue_id,
                    "task_id":task_id,
                    "turn":turn,
                    "question":question,
                    "response":response,
                    "datetime":curr_datetime}
        result = self.collection.insert_one(document)

    def get(self):
        return self.collection.find()