vqa-guessing-game / response_db.py
sedrickkeh's picture
change db to online db
1de1fd2
raw
history blame
821 Bytes
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()