I'm writing an app using Python and Kivy. I have a function that draws an image and exports it as a png. I'm trying to use that image and save it in a sql db as a BLOB.
The route I'm trying to take is to convert the png in to a stream using BytesIO and then placing this value (string) in to a variable which I can then send in to a db.
The issue I'm having is that within the 'local' function I'm able to convert the png object into a stream and print it BUT when I try print this same variable outside of the function it returns empty.
Any insight help would be wonderfully appreciated! I think it's because I'm using the function's memory to convert the png>IO and when leaving the function it doesn't like it. Or if you have any better solutions I'm all ears.
def savevar(self):
global driversig
data = io.BytesIO(open("B.png","r+b").read())
test = (data.getvalue())
#i've also tried wrapping this in a str() but getvalue() is a string so shouldn't matter?
driversig = test
print(driversig)
#this prints fine.
When I try print(driversig)
outside of this function it returns empty
I've also tried print(str(driversig))
my global variable is empty. driversig = ''
just incase you were wondering. I also don't get any errors when print