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

Поиск
Список
Период
Сортировка
От VENKTESH GUTTEDAR
Тема Re: Appending new data to existing field of Json data type
Дата
Msg-id CA+iwz4=hWpg0Gp5HcoWppLicgUPk25iD==c=OezD-2g4yZawoQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Appending new data to existing field of Json data type  (Adrian Klaver <adrian.klaver@aklaver.com>)
Ответы Re: Appending new data to existing field of Json data type  (Adrian Klaver <adrian.klaver@aklaver.com>)
Re: Appending new data to existing field of Json data type  (Adrian Klaver <adrian.klaver@aklaver.com>)
Список pgsql-general
@Adrian Klaver, Thanks for this idea but still m really confused with how to update the json filed in the DB. is there any way to update the json field in the DB through view.?

On Wed, Oct 29, 2014 at 7:37 PM, Adrian Klaver <adrian.klaver@aklaver.com> wrote:
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@aklaver.com



--
Regards :
Venktesh Guttedar.

В списке pgsql-general по дате отправления:

Предыдущее
От: Fabio Ugo Venchiarutti
Дата:
Сообщение: Unexpected planner behavior with *_pattern_ops index matching
Следующее
От: Postgres India
Дата:
Сообщение: Re: DBlink, postgres to DB2