code example for CSV Importer with Node

Co-authored-by: Arpendu Kumar Garai <Arpendu.KumarGarai@microfocus.com>
This commit is contained in:
Arpendu Kumar Garai
2022-12-05 04:20:13 +05:30
committed by GitHub
parent 3930e1cb03
commit cd69fa5842
27 changed files with 915 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
import Sequelize from 'sequelize';
import dbConfig from '../config/db.config.js';
export const sequelize = new Sequelize(dbConfig.DB, dbConfig.USER, dbConfig.PASSWORD, {
host: dbConfig.HOST,
dialect: dbConfig.dialect,
pool: dbConfig.pool,
logging: console.log
}
);
sequelize.authenticate()
.then(() => {
console.log('Connection has been established successfully.');
console.log('Creating tables ===================');
sequelize.sync().then(() => {
console.log('=============== Tables created per model');
})
.catch(err => {
console.error('Unable to create tables:', err);
})
})
.catch(err => {
console.error('Unable to connect to the database:', err);
});