code example for CSV Importer with Node
Co-authored-by: Arpendu Kumar Garai <Arpendu.KumarGarai@microfocus.com>
This commit is contained in:
committed by
GitHub
parent
3930e1cb03
commit
cd69fa5842
25
nodejs/node-csv-importer/server/database/index.js
Normal file
25
nodejs/node-csv-importer/server/database/index.js
Normal 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);
|
||||
});
|
||||
Reference in New Issue
Block a user