当前位置: 首页>>代码示例>>Python>>正文


Python DbSession.query方法代码示例

本文整理汇总了Python中yt_crawler.backend.database.DbSession.query方法的典型用法代码示例。如果您正苦于以下问题:Python DbSession.query方法的具体用法?Python DbSession.query怎么用?Python DbSession.query使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yt_crawler.backend.database.DbSession的用法示例。


在下文中一共展示了DbSession.query方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_duration_of_all_videos_per_youtuber

# 需要导入模块: from yt_crawler.backend.database import DbSession [as 别名]
# 或者: from yt_crawler.backend.database.DbSession import query [as 别名]
 def get_duration_of_all_videos_per_youtuber():
     existing = DbSession.query(func.count(Video.video_id), Youtuber.channel_title).filter(Video.type.isnot(VideoType.EXISTING.video_type_id)).join(Youtuber).group_by(Video.channel_id).all()
     purged = DbSession.query(func.count(PurgedVideo.video_id), Youtuber.channel_title).join(Youtuber).group_by(PurgedVideo.channel_id).all()
     existing_result = [(ex[0], ex[1]) for ex in existing]
     for ex in existing_result:
         matching = next((purged_video for purged_video in purged if ex[1] == purged_video[1]), None)
         if matching is not None:
             existing_result[existing_result.index(ex)] = (ex[0] + matching[0], ex[1])
     return existing_result
开发者ID:Sheldan,项目名称:yt_crawler,代码行数:11,代码来源:youtube_model.py

示例2: get_existing_stat_for_youtuber

# 需要导入模块: from yt_crawler.backend.database import DbSession [as 别名]
# 或者: from yt_crawler.backend.database.DbSession import query [as 别名]
 def get_existing_stat_for_youtuber(self):
     existing = DbSession.query(func.count(Video.video_id), func.sum(Video.size)).filter(and_(Video.type.isnot(VideoType.EXISTING.video_type_id), (Video.channel_id == self.channel_id))).all()
     purged = DbSession.query(func.count(PurgedVideo.video_id), func.sum(PurgedVideo.size)).filter(PurgedVideo.channel_id == self.channel_id).all()
     old_statistic = DbSession.query(Statistic.number_downloaded, Statistic.size_downloaded).filter(Statistic.channel_id == self.channel_id).all()
     count = 0
     size = 0
     # old_statistic is grouped into types
     for stat in old_statistic:
         count += int(stat[0])
         size += int(stat[1])
     return [int(existing[0][0]) + int(purged[0][0]) + count, int(existing[0][1]) + int(purged[0][1]) + size]
开发者ID:Sheldan,项目名称:yt_crawler,代码行数:13,代码来源:youtube_model.py

示例3: get_all_audio_files_from_channel

# 需要导入模块: from yt_crawler.backend.database import DbSession [as 别名]
# 或者: from yt_crawler.backend.database.DbSession import query [as 别名]
 def get_all_audio_files_from_channel(channel_id):
     return DbSession.query(Audio).join(Video).filter(Video.channel_id==channel_id).all()
开发者ID:Sheldan,项目名称:yt_crawler,代码行数:4,代码来源:youtube_model.py

示例4: delete_playlist_item

# 需要导入模块: from yt_crawler.backend.database import DbSession [as 别名]
# 或者: from yt_crawler.backend.database.DbSession import query [as 别名]
 def delete_playlist_item(playlist_id, video_id):
     playlist_item = DbSession.query(PlaylistItem).filter(
         and_(PlaylistItem.playlist_id == playlist_id, PlaylistItem.video_id == video_id)).first()
     playlist = DbSession.query(Playlist).filter(Playlist.playlist_id == playlist_id).one()
     playlist.playlist_items.remove(playlist_item)
     PlaylistItem.commit()
开发者ID:Sheldan,项目名称:yt_crawler,代码行数:8,代码来源:youtube_model.py

示例5: get_whole_audio_info

# 需要导入模块: from yt_crawler.backend.database import DbSession [as 别名]
# 或者: from yt_crawler.backend.database.DbSession import query [as 别名]
 def get_whole_audio_info(video_id):
     return DbSession.query(Audio, Video, Youtuber, Artist, Album, Cover).join(Video).join(Youtuber).outerjoin(Artist).outerjoin(Album).outerjoin(Cover).filter(and_(Video.stored.is_(True), Audio.video_id == video_id)).all()
开发者ID:Sheldan,项目名称:yt_crawler,代码行数:4,代码来源:youtube_model.py

示例6: load_all

# 需要导入模块: from yt_crawler.backend.database import DbSession [as 别名]
# 或者: from yt_crawler.backend.database.DbSession import query [as 别名]
 def load_all(cls):
     return DbSession.query(cls).all()
开发者ID:Sheldan,项目名称:yt_crawler,代码行数:4,代码来源:mixins.py

示例7: get_number_filtered

# 需要导入模块: from yt_crawler.backend.database import DbSession [as 别名]
# 或者: from yt_crawler.backend.database.DbSession import query [as 别名]
 def get_number_filtered(cls, **kwargs):
     q = DbSession.query(cls)
     filters = [getattr(cls, field_name) == kwargs[field_name] for field_name in kwargs]
     return q.filter(and_(*filters)).count()
开发者ID:Sheldan,项目名称:yt_crawler,代码行数:6,代码来源:mixins.py

示例8: get_audio_files

# 需要导入模块: from yt_crawler.backend.database import DbSession [as 别名]
# 或者: from yt_crawler.backend.database.DbSession import query [as 别名]
 def get_audio_files(self):
     return DbSession.query(Audio, Video, Youtuber).join(Video).join(Youtuber).filter(Video.channel_id == self.channel_id).all()
开发者ID:Sheldan,项目名称:yt_crawler,代码行数:4,代码来源:youtube_model.py

示例9: save_to_delete

# 需要导入模块: from yt_crawler.backend.database import DbSession [as 别名]
# 或者: from yt_crawler.backend.database.DbSession import query [as 别名]
 def save_to_delete(self):
     video_part = self.type == DownloadFlag.CRAWLED or self.type == DownloadFlag.SCHEDULED
     audio_part = DbSession.query(Audio).filter(Audio.video_id == self.video_id)
     playlist_item_part = PlaylistItem.exists(video_id=self.video_id)
     return not (audio_part and video_part and playlist_item_part)
开发者ID:Sheldan,项目名称:yt_crawler,代码行数:7,代码来源:youtube_model.py

示例10: get_duration_of_videos_per_youtuber

# 需要导入模块: from yt_crawler.backend.database import DbSession [as 别名]
# 或者: from yt_crawler.backend.database.DbSession import query [as 别名]
 def get_duration_of_videos_per_youtuber():
     return DbSession.query(func.sum(Video.duration), Youtuber.channel_title).filter(and_(Video.type.isnot(VideoType.EXISTING.video_type_id)), Video.stored.is_(True)).join(Youtuber).group_by(Video.channel_id).all()
开发者ID:Sheldan,项目名称:yt_crawler,代码行数:4,代码来源:youtube_model.py

示例11: get_pending_converted_videos

# 需要导入模块: from yt_crawler.backend.database import DbSession [as 别名]
# 或者: from yt_crawler.backend.database.DbSession import query [as 别名]
 def get_pending_converted_videos():
     return DbSession.query(Video).filter(Video.to_be_converted.is_(True)).all()
开发者ID:Sheldan,项目名称:yt_crawler,代码行数:4,代码来源:youtube_model.py

示例12: get_purged_videos

# 需要导入模块: from yt_crawler.backend.database import DbSession [as 别名]
# 或者: from yt_crawler.backend.database.DbSession import query [as 别名]
 def get_purged_videos(self):
     return DbSession.query(PurgedVideo).filter(PurgedVideo.channel_id == self.channel_id).all()
开发者ID:Sheldan,项目名称:yt_crawler,代码行数:4,代码来源:youtube_model.py

示例13: get_youtuber_who_have_purged_videos

# 需要导入模块: from yt_crawler.backend.database import DbSession [as 别名]
# 或者: from yt_crawler.backend.database.DbSession import query [as 别名]
 def get_youtuber_who_have_purged_videos():
     return DbSession.query(PurgedVideo, Youtuber).join(Youtuber).group_by(PurgedVideo.channel_id).all()
开发者ID:Sheldan,项目名称:yt_crawler,代码行数:4,代码来源:youtube_model.py

示例14: get_youtuber_with_pending_converted_videos

# 需要导入模块: from yt_crawler.backend.database import DbSession [as 别名]
# 或者: from yt_crawler.backend.database.DbSession import query [as 别名]
 def get_youtuber_with_pending_converted_videos():
     youtuber_list = DbSession.query(Video).options(load_only('channel_id')).filter(Video.to_be_converted.is_(True)).group_by(Video.channel_id).all()
     actual_list = [youtuber.channel_id for youtuber in youtuber_list]
     return DbSession.query(Youtuber).filter(Youtuber.channel_id.in_(actual_list)).all()
开发者ID:Sheldan,项目名称:yt_crawler,代码行数:6,代码来源:youtube_model.py

示例15: get_youtuber_which_have_videos_with_type

# 需要导入模块: from yt_crawler.backend.database import DbSession [as 别名]
# 或者: from yt_crawler.backend.database.DbSession import query [as 别名]
 def get_youtuber_which_have_videos_with_type(video_type):
     youtuber_list = DbSession.query(Video).options(load_only('channel_id')).filter(Video.video_type == video_type).group_by(Video.channel_id).all()
     actual_list = [youtuber.channel_id for youtuber in youtuber_list]
     return DbSession.query(Youtuber).filter(and_(Youtuber.channel_id.in_(actual_list), Video.video_type == video_type)).all()
开发者ID:Sheldan,项目名称:yt_crawler,代码行数:6,代码来源:youtube_model.py


注:本文中的yt_crawler.backend.database.DbSession.query方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。