AutomationFlowsData & Sheets › Import CSV to Postgres Automatically

Import CSV to Postgres Automatically

Original n8n title: How to Automatically Import CSV Files Into Postgres

How to automatically import CSV files into postgres. Uses manualTrigger, readBinaryFile, spreadsheetFile, postgres. Event-driven trigger; 4 nodes.

Event trigger★★☆☆☆ complexity4 nodesRead Binary FileSpreadsheet FilePostgres
Data & Sheets Trigger: Event Nodes: 4 Complexity: ★★☆☆☆ Added:

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "id": "q8GNbRhjQDwDpXoo",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "How to automatically import CSV files into postgres",
  "tags": [],
  "nodes": [
    {
      "id": "9ae270f2-6e32-4a14-8a03-634b9c66004d",
      "name": "On clicking 'execute'",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -340,
        -80
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "96de1409-9c48-4357-aaef-2202dec478a9",
      "name": "Read From File",
      "type": "n8n-nodes-base.readBinaryFile",
      "position": [
        -140,
        -80
      ],
      "parameters": {
        "filePath": "/tmp/t1.csv"
      },
      "typeVersion": 1
    },
    {
      "id": "22b002df-51fd-4074-8741-c9a754996170",
      "name": "Convert To Spreadsheet",
      "type": "n8n-nodes-base.spreadsheetFile",
      "position": [
        60,
        -80
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "0ec04e46-be13-40c3-a4a4-60787bf02a1f",
      "name": "Postgres",
      "type": "n8n-nodes-base.postgres",
      "position": [
        320,
        -80
      ],
      "parameters": {
        "table": {
          "__rl": true,
          "mode": "name",
          "value": "t1"
        },
        "schema": {
          "__rl": true,
          "mode": "list",
          "value": "public",
          "cachedResultName": "public"
        },
        "columns": {
          "value": {
            "id": 0
          },
          "schema": [
            {
              "id": "id",
              "type": "number",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "id",
              "defaultMatch": true,
              "canBeUsedToMatch": true
            },
            {
              "id": "name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "autoMapInputData",
          "matchingColumns": [
            "id"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.5
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "332ff892-d7c2-4e11-8119-e95a2ded82e7",
  "connections": {
    "Read From File": {
      "main": [
        [
          {
            "node": "Convert To Spreadsheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "On clicking 'execute'": {
      "main": [
        [
          {
            "node": "Read From File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert To Spreadsheet": {
      "main": [
        [
          {
            "node": "Postgres",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

How to automatically import CSV files into postgres. Uses manualTrigger, readBinaryFile, spreadsheetFile, postgres. Event-driven trigger; 4 nodes.

Source: https://github.com/Zie619/n8n-workflows — original creator credit. Request a take-down →

More Data & Sheets workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

Data & Sheets

-- Disclaimer: This template is mainly made for self-hosted users who can reach CSV files in their file system. For Cloud users, just replace the first few nodes with your file system of choice, like

Read Binary File, Spreadsheet File, Postgres
Data & Sheets

Convert Postgresql Table To Csv. Uses manualTrigger, spreadsheetFile, postgres. Event-driven trigger; 4 nodes.

Spreadsheet File, Postgres
Data & Sheets

Import Csv Into Mysql. Uses manualTrigger, readBinaryFile, spreadsheetFile, mySql. Event-driven trigger; 4 nodes.

Read Binary File, Spreadsheet File, MySQL
Data & Sheets

PostgreSQL export to CSV. Uses manualTrigger, spreadsheetFile, postgres. Event-driven trigger; 4 nodes.

Spreadsheet File, Postgres
Data & Sheets

This workflow demonstrates how CSV file can be automatically imported into existing MySQL database.

Read Binary File, Spreadsheet File, MySQL