Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to store base64 information in a MySQL table?

Tags:

python

mysql

I've done some research, and I don't fully understand what I found.

My aim is to, using a udp listener I wrote in python, store data that it receives from an MT4000 telemetry device. This data is received and read in hex, and I want that data to be put into a table, and store it as a string in base64. In terms of storing something as an integer by using the 'columnname' INT format, I would like to know how to store the information as base64? ie. 'data' TEXT(base64)? or something similar.

Could I do this by simply using the TEXT datatype, and encode the data in the python program?

I may be approaching this in the wrong way, as I may have misinterpreted what I read online. I would be very grateful for any help. Thanks,

Ed

like image 903
Ed Prince Avatar asked Sep 02 '25 04:09

Ed Prince


1 Answers

You can just save the base64 string in a TEXT column type. After retrieval just decode this string with base64.decodestring(data) !

like image 159
sosta Avatar answered Sep 04 '25 18:09

sosta