0

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.

0

1 Answer 1

1

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)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.