from entity.KeyWordEntity import Keyword from common.Utils import getSession from sqlalchemy import update class KeyWordService: def insertOne(region, word): session = getSession() keyWord: Keyword = Keyword(region=region, word=word) session.add(keyWord) session.commit() session.close() def queryOneByRegionWord(region, word): session = getSession() keyWord: Keyword = session.query(Keyword).filter( Keyword.region == region, Keyword.word == word).one_or_none() session.close() return keyWord def insterKeyWords(keyWords): session = getSession() session.bulk_save_objects(keyWords) session.commit() session.close()