首页 > 解决方案 > 自动将 csv 转储到新的 Postgres 表中

问题描述

我有数千个 csv,每个 csv 有超过 10000 条记录。我正在寻找以最少的时间和精力将这些数据转储到 Postgres DB 表中的最有效方法。

标签: pythonpostgresql

解决方案


COPY is usually the best solution. Depends of your constraints.

COPY table_name FROM 'path_readable_by_postgres/file.cvs';

And you can cat your files in a big one to import data quickly.

Look ta https://www.postgresql.org/docs/current/static/sql-copy.html for more details.


推荐阅读