Wednesday, October 9, 2013

Re: Retrieving json stored in TextField as json

I'm using django-json-field [1] for solving the same problem.

[1] https://github.com/derek-schaefer/django-json-field

HTH
El 09/10/2013, a las 16:01, Marc Aymerich <glicerinu@gmail.com> escribió:

> Hi,
> I'm storing large volumes of json data in a TextFields, Then I have a
> view that converts this text data into JSON, but this silly operation
> requires a considerable amount of resources for a large dataset.
>
> It would be nice if I'm able to retrieve native JSON directly from the database.
>
> As you can see value is "almost" json, the only problem is that is
> wrapped around quotes :)
>
>>>> TimeSerie.objects.filter(type='cpu').values('value')
> [{'value': '{"scheduled":2,"total":864,"15min":0.38,"1min":0.3,"5min":0.48}'},
> {'value': '{"scheduled":2,"total":859,"15min":0.34,"1min":0.23,"5min":0.32}'},
> {'value': '{"scheduled":2,"total":849,"15min":0.33,"1min":0.51,"5min":0.32}'},
> {'value': '{"scheduled":2,"total":814,"15min":0.3,"1min":0.2,"5min":0.25}'},
> {'value': '{"scheduled":2,"total":817,"15min":0.25,"1min":0.14,"5min":0.17}'},
> {'value': '{"scheduled":2,"total":815,"15min":0.22,"1min":0.18,"5min":0.14}'}]
>
> Any suggestion in how I can speed this up by avoiding to convert each
> element to json by iterating on the query results?
>
> I'm using psotgresql 9.3 with native json support, not sure if it is
> relevant or not :)
>
> --
> Marc
>
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2BDCN_vTbC0-yOt7cuToYLZSOD%2B%3DZCubLOjgkpu-MyB1VxbGMA%40mail.gmail.com.
> For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/646FABCC-B4DB-4EE7-BC54-B0C5A2C7C25F%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate