def insert_tagInfo(tag): tagInfo = session.query(TagInfo).filter_by(name=tag).first() if not tagInfo: tagInfo = TagInfo() tagInfo.name = tag session.add(tagInfo) session.commit() return tagInfo
def insert_gameInfo2TagInfo_not_exists(tagId, gameId): gameInfo2TagInfo = session.query(GameInfo2TagInfo).filter_by(tagId=tagId, gameId=gameId).first() if not gameInfo2TagInfo: gameInfo2TagInfo = GameInfo2TagInfo() gameInfo2TagInfo.tagId = tagId gameInfo2TagInfo.gameId = gameId session.add(gameInfo2TagInfo) session.commit() return gameInfo2TagInfo
def insert_gameInfo2CategoryInfo(categoryId, gameId): gameInfo2CategoryInfo = session.query(GameInfo2CategoryInfo) \ .filter_by(categoryId=categoryId, gameId=gameId).first() if not gameInfo2CategoryInfo: gameInfo2CategoryInfo = GameInfo2CategoryInfo() gameInfo2CategoryInfo.categoryId = categoryId gameInfo2CategoryInfo.gameId = gameId session.add(gameInfo2CategoryInfo) session.commit() return gameInfo2CategoryInfo
def insert_categoryInfo(id, name): category = session.query(CategoryInfo) \ .filter_by(id=id).first() if not category: category = CategoryInfo() category.id = id category.name = name session.add(category) session.commit() return category
def insert_GameInfo2VersionInfo_not_exists(versionId, gameId): gameInfo2VersionInfo = session.query(GameInfo2VersionInfo).filter_by( versionId=versionId, gameId=gameId).first() if not gameInfo2VersionInfo: gameInfo2VersionInfo = GameInfo2VersionInfo() gameInfo2VersionInfo.versionId = versionId gameInfo2VersionInfo.gameId = gameId session.add(gameInfo2VersionInfo) session.commit() return gameInfo2VersionInfo
def insert_versionInfo(url, total_size, version_name, versionCode, orientation): versionInfo = session.query(VersionInfo) \ .filter_by(url=url).first() if not versionInfo: versionInfo = VersionInfo() versionInfo.url = url versionInfo.total_size = total_size versionInfo.version_name = version_name versionInfo.version_code = versionCode versionInfo.orientation = orientation session.add(versionInfo) session.commit() return versionInfo