Search Postgresql Archives

Re: Appending new data to existing field of Json data type

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10/29/2014 01:06 AM, VENKTESH GUTTEDAR wrote:
Ya agreed thats not legal JSON, that was typing mistake sorry for that,

let me make you clear what i need exactly,

I have table named (exampleTable) with json field as (example_list), and
when i say
SELECT * FROM exampleTable;

id | example_list
---+----------------------------------------------
  2 | {"abc":[ { "a":"b","c":"d" } ] }


And this data i am inserting through DJango view by writing the
following statement

test = ExampleTable(id = 2, example_list = {"abc" : [ { "a":"b","c":"d"
} ] })
test.save()

now i want to append { "e":"f", "g":"h" } to example_list by specifying
the id.
and after appending the data should be stored in the following way :
After appending,
for example if i say :
SELECT * FROM exampleTable;
i should get this.

id | example_list
---+--------------------------------------------------------
  2 | {"abc":[ { "a":"b","c":"d" }, { "e":"f", "g":"h" } ] }

Hope your clear now.

So now Guide me to append it through Python Djnago View. or through raw
sql query.

If it where me I would bring the data into the view and do the work there in Python using dicts and lists. There is a Python module out there that make this easier to do:

https://pypi.python.org/pypi/django-jsonfield




--
Regards :
Venktesh Guttedar.



--
Adrian Klaver
adrian.klaver@xxxxxxxxxxx


--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux