How to import CSV file data into a PostgreSQL table?

前端 未结 19 2347
再見小時候
再見小時候 2020-11-22 02:14

How can I write a stored procedure that imports data from a CSV file and populates the table?

19条回答
  •  后悔当初
    2020-11-22 03:01

    You can also use pgfutter, or, even better, pgcsv.

    pgfutter is quite buggy, I'd recomment pgcsv.

    Here's how to do it with pgcsv:

    sudo pip install pgcsv
    pgcsv --db 'postgresql://localhost/postgres?user=postgres&password=...' my_table my_file.csv
    

提交回复
热议问题