• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python database.DbSession类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: get_duration_of_all_videos_per_youtuber

 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,代码行数:9,代码来源:youtube_model.py


示例2: get_existing_stat_for_youtuber

 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,代码行数:11,代码来源:youtube_model.py


示例3: setup_constants

 def setup_constants():
     VideoType.PLAYLIST_ITEM = VideoType.load(name=DownloadFlag.PLAYLIST_ITEM.value)
     VideoType.SCHEDULED = VideoType.load(name=DownloadFlag.SCHEDULED.value)
     VideoType.CRAWLED = VideoType.load(name=DownloadFlag.CRAWLED.value)
     VideoType.EXISTING = VideoType.load(name=DownloadFlag.EXISTING.value)
     DbSession.expunge(VideoType.PLAYLIST_ITEM)
     DbSession.expunge(VideoType.SCHEDULED)
     DbSession.expunge(VideoType.CRAWLED)
     DbSession.expunge(VideoType.EXISTING)
开发者ID:Sheldan,项目名称:yt_crawler,代码行数:9,代码来源:youtube_model.py


示例4: insert_contants

 def insert_contants():
     if not ErrorFatality.exists(error_name='info'):
         DbSession.add(ErrorFatality(error_name='info'))
     if not ErrorFatality.exists(error_name='warning'):
         DbSession.add(ErrorFatality(error_name='warning'))
     if not ErrorFatality.exists(error_name='error'):
         DbSession.add(ErrorFatality(error_name='error'))
     if not ErrorFatality.exists(error_name='severe'):
         DbSession.add(ErrorFatality(error_name='severe'))
开发者ID:Sheldan,项目名称:yt_crawler,代码行数:9,代码来源:youtube_model.py


示例5: get_duration_of_videos_per_youtuber

 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,代码行数:2,代码来源:youtube_model.py


示例6: create_without_transaction

 def create_without_transaction(cls, **kwargs):
     instance = cls(**kwargs)
     DbSession.add(instance)
     return instance
开发者ID:Sheldan,项目名称:yt_crawler,代码行数:4,代码来源:mixins.py


示例7: get_number

 def get_number(cls):
     return DbSession.query(cls).count()
开发者ID:Sheldan,项目名称:yt_crawler,代码行数:2,代码来源:mixins.py


示例8: load_all

 def load_all(cls, **kwargs):
     q = DbSession.query(cls)
     filters = [getattr(cls, field_name) == kwargs[field_name] for field_name in kwargs]
     return q.filter(and_(*filters)).all()
开发者ID:Sheldan,项目名称:yt_crawler,代码行数:4,代码来源:mixins.py


示例9: save_to_delete

 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,代码行数:5,代码来源:youtube_model.py


示例10: load_with_youtuber

 def load_with_youtuber():
     return DbSession.query(Profile, Youtuber).join(YoutuberInProfile).join(Youtuber).all()
开发者ID:Sheldan,项目名称:yt_crawler,代码行数:2,代码来源:youtube_model.py


示例11: delete_audio_file

 def delete_audio_file(self):
     full_path = self.absolute_path
     DbSession.delete(self)
     if os.path.isfile(full_path):
         os.remove(full_path)
开发者ID:Sheldan,项目名称:yt_crawler,代码行数:5,代码来源:youtube_model.py


示例12: get_single_statistic

 def get_single_statistic(channel_id, video_type):
     return DbSession.query(Statistic).filter(
         and_(Statistic.channel_id == channel_id, Statistic.video_type == video_type)).one()
开发者ID:Sheldan,项目名称:yt_crawler,代码行数:3,代码来源:youtube_model.py


示例13: get_videos_after_time_stamp

 def get_videos_after_time_stamp(time_stamp):
     all_video_queue = DbSession.query(VideoQueueItem).options(Load(Video).load_only('video_id')).all()
     actual_list = [video.video_id for video in all_video_queue]
     return DbSession.query(VideoQueueItem, Video, Youtuber, VideoType, PlaylistItem, Playlist).filter(
         and_(Video.video_id.in_(actual_list), Video.downloaded_date > datetime.datetime.fromtimestamp(int(time_stamp)/1000))).order_by(
         Video.downloaded_date).all()
开发者ID:Sheldan,项目名称:yt_crawler,代码行数:6,代码来源:youtube_model.py


示例14: get_whole_video_queue_obj

 def get_whole_video_queue_obj():
     return DbSession.query(VideoQueueItem, Video, Youtuber, VideoType, PlaylistItem, Playlist).join(Video).join(Youtuber).join(VideoType)\
         .outerjoin(PlaylistItem).outerjoin(Playlist).order_by(asc(Video.downloaded_date)).all()
开发者ID:Sheldan,项目名称:yt_crawler,代码行数:3,代码来源:youtube_model.py


示例15: get_pending_converted_videos_by_channel_id

 def get_pending_converted_videos_by_channel_id(channel_id):
     return DbSession.query(Video).filter(and_(Video.to_be_converted.is_(True), Video.channel_id == channel_id)).all()
开发者ID:Sheldan,项目名称:yt_crawler,代码行数:2,代码来源:youtube_model.py


示例16: get_all_audio_information

 def get_all_audio_information():
     return DbSession.query(Audio, Video, Youtuber, Artist, Album, Cover).join(Video).join(Youtuber).outerjoin(Artist).outerjoin(Album).outerjoin(Cover).filter(Video.stored.is_(True)).all()
开发者ID:Sheldan,项目名称:yt_crawler,代码行数:2,代码来源:youtube_model.py


示例17: get_number_of_profiles

 def get_number_of_profiles():
     return DbSession.query(Profile).count()
开发者ID:Sheldan,项目名称:yt_crawler,代码行数:2,代码来源:youtube_model.py


示例18: get_whole_audio_info

 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,代码行数:2,代码来源:youtube_model.py


示例19: load

 def load(cls, **kwargs):
     q = DbSession.query(cls)
     filters = [getattr(cls, field_name) == kwargs[field_name] for field_name in kwargs]
     obj = q.filter(and_(*filters)).one()
     return obj
开发者ID:Sheldan,项目名称:yt_crawler,代码行数:5,代码来源:mixins.py


示例20: get_all_audio_files_from_channel

 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,代码行数:2,代码来源:youtube_model.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python yum._函数代码示例发布时间:2022-05-26
下一篇:
Python yt.load函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap