本文整理汇总了Python中db.Db.get_session方法的典型用法代码示例。如果您正苦于以下问题:Python Db.get_session方法的具体用法?Python Db.get_session怎么用?Python Db.get_session使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类db.Db
的用法示例。
在下文中一共展示了Db.get_session方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_transcoding
# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import get_session [as 别名]
def add_transcoding(cls, transcoding):
with DbWriteGuard():
session = Db.get_session()
session.add(transcoding)
session.commit()
cls.vacuum(session)
session.commit()
示例2: default
# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import get_session [as 别名]
def default(self, id = False):
q = Db.get_session().query(Artist)
if id and id.isdigit():
q = q.filter(Artist.id == int(id))
q = q.order_by(Artist.name)
return [ a.to_dict() for a in q ]
示例3: default
# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import get_session [as 别名]
def default(self, album_id = False, artist = False):
q = Db.get_session().query(Album)
if artist and artist.isdigit():
q = q.filter(Album.artist_id == int(artist))
if album_id and album_id.isdigit():
q = q.filter(Album.id == int(album_id))
return [ a.to_dict() for a in q ]
示例4: default
# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import get_session [as 别名]
def default(self, track_id = False, album = False):
q = Db.get_session().query(Track)
if album and album.isdigit():
q = q.filter(Track.album_id == int(album))
if track_id:
if track_id == 'random':
q = q.order_by(func.random()).limit(1)
elif track_id.isdigit():
q = q.filter(Track.id == int(track_id))
return [ a.to_dict() for a in q ]
示例5: default
# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import get_session [as 别名]
def default(self, album_id):
if not (album_id and album_id.isdigit()):
raise cherrypy.HTTPError(400)
q = Db.get_session().query(Album).filter(Album.id == int(album_id))
for album in q:
ret = AutoFile(album.tracks[0].file.path).get_picture()
if ret:
return ret
raise cherrypy.HTTPError(404)
示例6: get_cached_path
# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import get_session [as 别名]
def get_cached_path(cls, input, output):
session = Db.get_session()
query = session.query(Transcoding). \
filter(Transcoding.source_path == input.path). \
filter(Transcoding.format == output.format). \
filter(Transcoding.quality == output.quality). \
filter(Transcoding.bits_per_sample <= output.max_bits_per_sample). \
filter(Transcoding.sample_rate <= output.max_sample_rate)
for transcoding in query:
if not cls.validate_cached_path(input.path, transcoding.path):
session.delete(transcoding)
session.commit()
else:
return transcoding.path
return False