Re: inserting a text file via json

From: Emanuel Calvo <postgres(dot)arg(at)gmail(dot)com>
To: "john(dot)tiger" <john(dot)tigernassau(at)gmail(dot)com>
Cc: postgresql Forums <pgsql-general(at)postgresql(dot)org>
Subject: Re: inserting a text file via json
Date: 2014-09-08 12:19:40
Message-ID: CAGHEX6aaT659OHedBaKpbR4Z6Wyjkq27Z7YfQJjL2iNE2Z_R9g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Did you mean something like...?:

postgres=# \! echo "{\"menu\": { \"id\": \"file\" }}" >
/opt/pgdata/exampl.json
postgres=# select pg_read_file('/opt/pgdata/exampl.json');
pg_read_file
----------------------------
{"menu": { "id": "file" }}+

(1 row)

postgres=# select pg_read_file('/opt/bdr/bdr1/exampl.json')::json;
pg_read_file
----------------------------
{"menu": { "id": "file" }}+

(1 row)

postgres=# create table json_exam as select
pg_read_file('/opt/bdr/bdr1/exampl.json')::json as jsonColumn;
SELECT 1
postgres=# \d json_exam
Table "public.json_exam"
Column | Type | Modifiers
------------+------+-----------
jsoncolumn | json |

2014-09-05 20:51 GMT-03:00 john.tiger <john(dot)tigernassau(at)gmail(dot)com>:

> we want to store markdown text files into our json fields - can this be
> done ? I guess we could have a separate json field and bytea field for the
> markdown file but this might be difficult when it comes to our REST
> response - anyone do something like this ?
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

--
--
Emanuel Calvo http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Cal Heldenbrand 2014-09-08 13:16:06 Re: Querying a time range across multiple partitions
Previous Message Michael Paquier 2014-09-08 04:35:27 Re: xlog min recovery request is past current point -- is it real problem?