Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- UE5
- Material
- dfs
- DP
- dynamic
- github
- parameter
- 백준
- String
- Programming
- python
- c++
- 프로그래밍
- 시작해요 언리얼 2022
- 기초
- w3school
- 재귀
- Unreal Engine 5
- Tutorial
- Unity
- 파이썬
- Algorithm
- C#
- W3Schools
- 오류
- guide
- Class
- 문제풀이
- Basic
- loop
Archives
- Today
- Total
행복한 개구리
Node 팀프 21.07.12. Node Sequelize 본문
npm 초기화를 한 뒤
express, nodemon, sequelize, sequelize-auto, sequelize -cli -g를 시켜주었고 mysql2도 npm으로 설치했다.
sequelize init을 시켜주었다.
그리고 생성된 config파일에 내 DB에 맞게 비밀번호, 유저네임등을 바꿔주었으며, 마지막에 문서형식도 추가해주었다.
config파일 제일 아래에 배열형식에 맞추어 위와같이 작성해주었다.
const express = require("express");
const app = express();
const { Sequelize, DataTypes } = require("sequelize");
const mysql = require("mysql2");
const sequelize = new Sequelize("mysql", "root", "d394", {
host: "127.0.0.1",
dialect: "mysql",
});
const port = 3030;
app.get("/", (req,res)=>{
res.send("Hello Sequelize!");
});
app.get("/connectdb", (req,res)=>{
connect();
res.end("db connection test...");
});
async function connect(){
try{
await sequelize.authenticate(); //접속대기
console.log("connected.");
} catch(err){
console.log(err);
}
}
app.listen(port, ()=>{
console.log(`Waiting on ${port} port`);
})
그리고 해당 코드를 작성하고 로컬서버에서 구동하니 잘 작동된다.
'Unity > Project : Cursed Treasure 기획' 카테고리의 다른 글
Node 팀프 21.07.12. Sequelize-auto (0) | 2021.07.12 |
---|---|
Unity3D 팀프 21.06.29 CustomProperty로 태그변환 (0) | 2021.06.30 |