Python 以流的形式访问SQLAlchemy中的BLOB列
使用金字塔,我尝试用BLOB列的内容来响应。不幸的是,SQLAlchemy将BLOB的内容作为字节数组加载到内存中。有没有办法将BLOB作为流访问 我的模型如下所示:Python 以流的形式访问SQLAlchemy中的BLOB列,python,sqlalchemy,pyramid,Python,Sqlalchemy,Pyramid,使用金字塔,我尝试用BLOB列的内容来响应。不幸的是,SQLAlchemy将BLOB的内容作为字节数组加载到内存中。有没有办法将BLOB作为流访问 我的模型如下所示: class Image(Base): id = Column(Integer, primary_key=True) content = deferred(Column(BLOB)) 我试着在金字塔视图中访问它,就像这样 @view_config(route_name='myroute', request_meth
class Image(Base):
id = Column(Integer, primary_key=True)
content = deferred(Column(BLOB))
我试着在金字塔视图中访问它,就像这样
@view_config(route_name='myroute', request_method='GET')
def get_image(request: Request):
image = DBSession.query(Image).get(1)
resp = Response(content_type='image/jpeg')
# in this line SQLAlchemy loads the full content
resp.body = user.image.content
return resp
有没有一种方法可以将BLOB放入相应的应用程序中?恐怕只有在Oracle中才有可能-