How to add a current string into an already existing list
Denis McMahon
denismfmcmahon at gmail.com
Mon Nov 4 17:46:26 EST 2013
On Mon, 04 Nov 2013 19:03:58 +0200, Nick the Gr33k wrote:
> Please since this column you mentioned is able to store a Python's list
> datatype could you tell me what needs alternation in:
We've already told you, there is NO mysql datatype that can store a
python list directly. There are ways of storing lists in mysql, but you
can't pass a list directly into a mysql update or insert query as a
single record field (you may be able to pass a list of tuples in for a
multi row update or insert, but that's a different issue).
You could convert the python list into a storable entity, for example
imploding a list of strings with some arbitrary separator to create a
long string, store the long string, then when you read it from the
database explode it back into a list.
Or you could store each element of the list in a "downloads" tables along
with a reference to the associated record in the "users" table.
These are two possible methods of storing a list that is associated with
a user entry. Which method you use is up to you. There may be others.
Pick a method and code it.
There is no built in support in the python / mysql system for putting a
list straight into a database, because mysql does not have a "collection"
record type.
--
Denis McMahon, denismfmcmahon at gmail.com
More information about the Python-list
mailing list