cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Pearson <mjpear...@gmail.com>
Subject Re: how to store list data in Apache Cassndra ?
Date Tue, 06 Apr 2010 09:12:25 GMT
Column Families are keyed attribute/value pairs, your 'girls' column
will need to be serialised on save, and deserialiased on load so that
it can treated as your intended array.  Pickle will do this for you
(http://docs.python.org/library/pickle.html)

eg:

 import pycassa
 import pickle
 client = pycassa.connect()
 cf = pycassa.ColumnFamily(client, 'mygame', 'user')

 key = '1234567890'
 value = {
     'name': 'Lee Li',
     'age'; '21',
     'girls': pickle.dumps(['java', 'actionscript', 'python'])
 }

cf.insert(key, value)

hope that helps

-michael


On Tue, Apr 6, 2010 at 6:49 PM, Shuge Lee <shuge.lee@gmail.com> wrote:
> Dear firends:
>
> how to store list data in Apache Cassndra ?
>
> For example:
> user['lee'] = {
>     'name': 'lee',
>     'age'; '21',
>     'girls': ['java', 'actionscript', 'python'],
> }
> Notice key `gils`
>
> I using pycassa (a python lib of cassandra)
>
> import pycassa
> client = pycassa.connect()
> cf = pycassa.ColumnFamily(client, 'mygame', 'user')
>
> key = '1234567890'
> value = {
>     'name': 'Lee Li',
>
>     'age'; '21',
>     'girls': ['java', 'actionscript', 'python'],
> }
>
> cf.insert(key, value)
>
>
> Oops, get error while save a `value` like above.
>
> So, how to store list data in Apache Cassndra ?
>
>
> Thanks for reply.
>
>
>
>
> --
> Shuge Lee | Lee Li
>

Mime
View raw message