Skip to content

Instantly share code, notes, and snippets.

@jayu108
Created February 11, 2020 02:13
Show Gist options
  • Save jayu108/a2280b9d9314494f7588b28d171900a3 to your computer and use it in GitHub Desktop.
Save jayu108/a2280b9d9314494f7588b28d171900a3 to your computer and use it in GitHub Desktop.
sequelize 접속 test 예제 ( mysql 접속하기 , database=testdb, username=park, password=1234 인 경우)
const Sequelize = require('sequelize')
// const sequelize = new Sequelize('mysql://park:1234@localhost:3306/testdb')
const sequelize = new Sequelize('testdb', 'park', '1234', {
host: '127.0.0.1',
dialect: 'mysql', // 'mariadb' | 'postgres' | 'mssql'
port: 3306,
pool: {
max: 90,
mix: 0,
acquire: 60000,
idle: 10000
}
})
sequelize
.authenticate()
.then(() => {
console.log('연결성공!!!!')
})
.catch(err => {
console.error('연결실패 ==> ', err)
})
.finally( () => {
sequelize.close()
})
{
"name": "sequelize_test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"mysql2": "^2.1.0",
"sequelize": "^5.21.4"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment