Is it possible to store boolean values?
I tried storing a True value in BigTable, and got the error message:
TypeError: True could not be converted to bytes
Looking at the code in GitHub, the function _to_bytes
was used, and it throws an error if it cannot be converted to bytes.
Is there a recommended way to store boolean data? Or should I just cast True/False and then remember to convert the values back to Boolean when I retrieve the data?
You cannot store a Boolean type in BigTable using Python.
This is what the documentation says about the data types that can be stored in BigTable:
Cloud Bigtable treats all data as raw byte strings for most purposes
So it seems that the best option you have is, as you said, to cast "True/False" as Strings and convert the data back to Boolean when you get it.