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. The sql is done in python using the cursor object c.
c.execute("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:
dest_addr = '\x00\x13\xa2\x00\x40\xe9\x21\x93'
xbee.tx(dest_addr_long = dest_addr ,data=newState)
when i use
repr(dest_addr)
I get
'\x00\x13\xa2\x00@\xe9!\x93'
also
type(dest_addr)
gives
<type 'str'>
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.
repr(send_addr[0][0])
which returns
u'\\x00\\x13\\xa2\\x00\\x40\\xe9\\x21\\x93'
and
<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?**