简体   繁体   中英

How to import JSON file in PostgreSQL: COPY 1

I'm new at PostgreSQL. I'm trying to import JSON file into PostgreSQL table. I created an empty table:

covid19=# CREATE TABLE temp_cov(
covid19(# data jsonb
covid19(# );

and tried to copy my data from JSON in this table with this command in Command line:

cat output.json | psql -h localhost -p 5432 covid19 -U postgres -c "COPY temp_cov (data) FROM STDIN;" 

The output was just "COPY 1" and when I open my table in psql with

SELECT * FROM temp_cov;

But this command goes without an end and with this output.

输出

Unfortunately, I couldn't find an answer or some similar problem solution. Thank you in advance for your advices.

Also my json file is already modified to "not pretty" form and it has over than 11k lines.

Your data is there. psql is sending the row to the pager (likely more ?), and the pager can't deal with it very usably because it is too big. You can turn off the pager ( \pset pager off inside psql) or set the pager to a better program (PAGER=less or PSQL_PAGER=less as environment variables), but really none of those is going to be all that useful for viewing giant JSON data.

You have your data in PostgreSQL, now what do you want to do with it? Just looking at it within psql's pager is unlikely to be interesting.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM