DBHandler.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:CaptsLog 作者: jaehoonhwang 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号