Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/329.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 以流的形式访问SQLAlchemy中的BLOB列_Python_Sqlalchemy_Pyramid - Fatal编程技术网

Python 以流的形式访问SQLAlchemy中的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

使用金字塔,我尝试用BLOB列的内容来响应。不幸的是,SQLAlchemy将BLOB的内容作为字节数组加载到内存中。有没有办法将BLOB作为流访问

我的模型如下所示:

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中才有可能-