简体   繁体   中英

How to store base64 information in a MySQL table?

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

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

您可以在TEXT列类型中存储 base64 字符串,但根据我的经验,我建议使用LONGTEXT类型以避免大 base64 文本中的截断错误。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM