Nodejs/Express CSV Upload Download to MySQL/PostgreSQL
TIL
771
Male avatar

loveprogramming viết ngày 01/12/2020

-> Tutorial: Nodejs/Express CSV Upload Download to MySQL/PostgreSQL

Nodejs/Express CSV Upload Download to MySQL/PostgreSQL

Tutorial: Nodejs/Express CSV Upload Download to MySQL/PostgreSQL – Multer, Fast-CSV, Json2Csv, Sequelize

In the tutorial, I will introduce how to build a Nodejs/Express RestAPIs application to upload/import and download/extract data from multiple CSV files to MySQL or PostgreSQL database by:

Express is used to build Nodejs RestApis
Multer is used to upload/download CSV files
Sequelize ORM is used to manipulate data with MySQL/PostgreSQL
Json2csv is used to save data objects to CSV file
fast-csv is used to parse CSV file to data objects

Architecture - Nodejs/Express Upload Download CSV Files

Architecture - Nodejs/Express Upload Download CSV Files

We build Nodejs RestAPIs on the top of Express framework and use the Multer library to handle upload multiple CSV files. For handling the business processing of our application, We implement a Controller.js that uses fast-csv and json2csv libraries to write/read data objects to CSV files. And for doing CRUD operations with MySQL and PostgreSQL database, we use Sequelizez ORM to finalize the jobs.

PROJECT STRUCTURE

Project Structure

  • config package is used to setup database configuration with Sequelize ORM and Multer’s configuration for uploading file
  • models package is used to define Sequelize Customer model
  • routers package is used to define Express router for Nodejs RestAPIs
  • controllers is used to implement coding to read/write CSV files and interact with database (storing/retrieving)
  • view package is used to define a html view page for upload/download CSV files
  • resource/static/js is used to implement Ajax Javascript code to upload multiples CSV files

RESULTS

Upload Multiple CSV Files – Results

Check MySQL database:

Nodejs Upload CSV File Successfully – Check MySQL records

Tutorial Link

Nodejs/Express CSV Upload Download to MySQL/PostgreSQL

Related post

Bình luận


White
{{ comment.user.name }}
Bỏ hay Hay
{{comment.like_count}}
Male avatar
{{ comment_error }}
Hủy
   

Hiển thị thử

Chỉnh sửa

Male avatar

loveprogramming

30 bài viết.
32 người follow
Kipalog
{{userFollowed ? 'Following' : 'Follow'}}
Bài viết liên quan
White
0 5
fCC: Technical Documentation Page note So I have finished the HTML part of this exercise and I want to come here to lament about the lengthy HTML ...
HungHayHo viết hơn 2 năm trước
0 5
White
4 0
I used Spring boot, Hibernate few times back then at University, I'v started using it again recently. In this (Link), I want to check how Spring J...
Rey viết 2 năm trước
4 0
White
24 1
Toán tử XOR có tính chất: + A XOR A = 0 + 0 XOR A = A Với tính chất này, có thể cài đặt bài toán sau với độ phức tạp O(N) về runtime, và với O(1)...
kiennt viết hơn 4 năm trước
24 1
{{like_count}}

kipalog

{{ comment_count }}

bình luận

{{liked ? "Đã kipalog" : "Kipalog"}}


Male avatar
{{userFollowed ? 'Following' : 'Follow'}}
30 bài viết.
32 người follow

 Đầu mục bài viết

Vẫn còn nữa! x

Kipalog vẫn còn rất nhiều bài viết hay và chủ đề thú vị chờ bạn khám phá!