Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PostgreSQL将JSONB列转储到行JSON文件中_Json_Postgresql - Fatal编程技术网

PostgreSQL将JSONB列转储到行JSON文件中

PostgreSQL将JSONB列转储到行JSON文件中,json,postgresql,Json,Postgresql,我知道我总是可以用一些脚本语言(如Python)检查驱动程序。但我想让事情变得简单 在一个PostgreSQL数据库中,我有一个表,它保存了一列来自Twitter的原始tweets。我试图通过以下方式将该列转储到一行JSON文件中: psql -U UUU -h HHH -c "COPY rawtwts(tweet) TO stdout CSV QUOTE E'\b' NULL AS ''" | gzip > dump.json.gz 然后我意识到我需要做一系列的tr-d和sed来修剪转

我知道我总是可以用一些脚本语言(如
Python
)检查驱动程序。但我想让事情变得简单

在一个
PostgreSQL
数据库中,我有一个表,它保存了一列来自Twitter的原始tweets。我试图通过以下方式将该列转储到一行JSON文件中:

psql -U UUU -h HHH -c "COPY rawtwts(tweet) TO stdout CSV QUOTE E'\b' NULL AS ''" | gzip > dump.json.gz
然后我意识到我需要做一系列的
tr-d
sed
来修剪转义字符和奇怪字符,然后再解析行JSON tweet文件,这会产生反效果

CSV QUOTE E'\b'
允许我通过
tr-d'\010'
过滤转义。否则,在文本模式下,JSON将包含以下内容:

, "source": "<a href=\\"https://mobile.twitter.com\\" rel=\\"nofollow\\">Twitter Web App</a>"
,“源”:

有没有简单方法的建议?

如果您在没有
copy
命令的情况下转储数据,但使用
psql
\t\a\o file.json从rawtts中选择row\u json(r)作为r,会怎样
如果不使用
copy
命令转储数据,但使用
psql
转储数据会怎么样:
\t\a\o file.json从RAWTWT中选择row_to_json(r)作为r