Riak & Timestamps (Python)

Rexxe rexxe98 at gmail.com
Sat Apr 2 21:23:48 EDT 2011


Bucket keys are strings and you're passing an int (data['Time(PDT)'] which
you set to int(ut))

On Sat, Apr 2, 2011 at 6:13 PM, Mike Stoddart <stodge at gmail.com> wrote:

> Just want to quickly clarify how to store timestamps in Riak Search
> using Python. My code:
>
>                dt = datetime.datetime.strptime(data['Time(PDT)'], "%b %d,
> %Y %H:%M:%S")
>                ut = time.mktime(dt.timetuple())
>                data['Time(PDT)'] = int(ut)
>
>                # Save the object to Riak.
>                json = simplejson.dumps(data)
>                obj = bucket.new(data['Time(PDT)'], data=json)
>                obj.store(return_body=False)
>
> This is giving me:
>
> TypeError: 1275598830 has type <type 'int'>, but expected one of:
> (<type 'str'>,)
>
> Am I misunderstanding something fundamental here?
>
> Thanks
> Mike
>
> _______________________________________________
> riak-users mailing list
> riak-users at lists.basho.com
> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.basho.com/pipermail/riak-users_lists.basho.com/attachments/20110402/30385604/attachment.html>


More information about the riak-users mailing list