Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我目前已经用dbext插件设置了 Vim 来对数据库运行查询。运行查询后,它会为输出结果创建一个新缓冲区。
dbext
到目前为止,如果我只想查看查询的输出,此设置可以正常工作,但我想将查询输出写入 CSV 文件,以便我可以在其他地方使用它。
有没有好的方法来做到这一点?
我发现如果我去缓冲区并说:w filename我可以将输出保存为文件,但问题是 dbext 的默认输出没有像正确的 CSV 文件那样格式化。
:w filename
如果您的数据库是 PostgreSQL,那么您可以将查询包装在例如
COPY (<put-query-here>) TO STDOUT WITH (FORMAT CSV);
我相信其他数据库也有类似的解决方案。