I have a 64 bit address that i want to store in a sqlite db column. The column is of type VARCHAR. This is how i store the data to the db.
INSERT INTO SENSORS(XBEE_ID) VALUES ('\x00\x13\xA2\x00\x40\xe9\x21\x9d');
I want to then read that address from the database and pass it to a function that will then send the data to some xbees. I am using a xbee library that accepts the address in the form
xbee.tx(dest_addr_long = '\x00\x13\xa2\x00\x40\xe9\x21\x93',data=newState)
But when I read the data from the database, and store to a variable,I get an error "the data provided for 'dest_addr_long' was not 8 bytes long.
addr_long = c.fetchall()
addr_long2 = addr_long([0][0])
xbee.tx(dest_addr_long = addr_long2,data=newState)
when i read the data from the db it is of type unicode, so i tried this - Convert a Unicode string to a string in Python (containing extra symbols) but it did not work.
I am basically looking for the opposite of this . Converting string into hex representation
so my questions, is my method right for storing the data in the db? how can I manipulate the data so that I can get it in the string type that is required for the function?
Aucun commentaire:
Enregistrer un commentaire