Python Forum
Python and SQL BLOB Streaming - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Python and SQL BLOB Streaming (/thread-9998.html)



Python and SQL BLOB Streaming - ashtona - May-08-2018

Hello, I have some videos I am storing on an SQL BLOB column. Is there a way I could read from the columns in byte chunks to create a stream in python?

Any help on this would be greatly, greatly appreciated.


RE: Python and SQL BLOB Streaming - Larz60+ - May-08-2018

this looks to be about reading blob data in chunks, (SQL Server): https://stackoverflow.com/questions/13777840/how-do-i-select-just-a-portion-of-huge-binary-file?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa


RE: Python and SQL BLOB Streaming - ashtona - May-09-2018

Ok so I can get the bytes, is there a way I can convert them to a image using PIL or something and feed them to a video player?

Thanks


RE: Python and SQL BLOB Streaming - Larz60+ - May-09-2018

Please refer to: https://code-maven.com/create-images-with-python-pil-pillow
as there are several writing modes, including text.


RE: Python and SQL BLOB Streaming - ashtona - May-09-2018

Read through that, still not sure how I can shove bytes in there to create an image. If I have the bytes there has to be a way to get frames out of them right? How else are streams created? I tried this

image.open(io.BytesIO(values[0][0]))

my values[0][0] contains a portion of my video file in bytes

I get this error cannot identify image file <_io.BytesIO object at 0x0000025D891FF200>.