def insert_to_entries_table(self, title, tags, markdown_text):
"""Insert Data into the Entries_Table in the Database
Args:
title (str): Title of the Journel Entry
tags (list): Tags for the Entry
markdown_text(str): Content of the Entry(Markdown text)
return:
result(bool): True for success or False for failure
"""
if title == str(""):
# print "Error!! Title Can't be Empty"
return False
entry = {"Title": title,
"Date_Created": datetime.now(),
"Last_Modified": datetime.now(),
"Tags": tags,
"MarkdownFile": markdown_text}
t = self.db["Entries_Table"]
try:
if t.insert_one(entry):
return True
except errors.ServerSelectionTimeoutError:
print('ERROR : No connection could be made because'
' the target machine actively refused it')
return True
评论列表
文章目录