How would you insert a tuple of strings to a sql column? At the moment I concatenate the strings in the tuple with a token and then when I read out the value again I split on this token.
1 Answer
Or you could use the pickle (or cPickle) module, it's probably easier than rolling your own code:
import pickle
my_tuple = ('one', 'two', 'three')
pickle.dumps(my_tuple) # <-- insert that into DB
to read it out, just pull the string out of the DB and call:
my_reconstituted_tuple = pickle.loads(data_from_db)