Toggle navigation
Toggle navigation
This project
Loading...
Sign in
MotherProject
/
Probability Death
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
배희수
2018-12-08 19:09:03 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
f107c0cbea0adb47083b8668e457bbd223b0ea83
f107c0cb
1 parent
f203460e
db 연동 쿼리문 작성 및 변수 초기화
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
4 deletions
routes/index.js
routes/index.js
View file @
f107c0c
var
express
=
require
(
'express'
);
var
router
=
express
.
Router
();
var
mysql
=
require
(
'mysql'
);
var
db
=
require
(
'../lib/db'
)
/* GET home page. */
router
.
get
(
'/'
,
function
(
req
,
res
,
next
)
{
// connection.query('SELECT * FROM ');
// 자외선지수, 불쾌지수, 열지수, 체감 온도, 바람속도, 현재기온, 하늘 상태, 강우량, 태풍, 낙뢰
var
uvr
,
discomfort
,
heat
,
sensibleTem
,
windSpeed
,
presentTem
,
skyState
,
rainfall
,
typhoon
,
lightning
;
// 사망 확률
var
deathProb
;
// 쿼리문
var
sql
=
'SELECT * FROM kkonzi_test.weatherInfo'
;
db
.
query
(
sql
,
function
(
err
,
rows
,
fields
){
if
(
err
)
{
console
.
log
(
err
);
}
else
{
var
tmp
=
rows
.
length
-
1
;
uvr
=
rows
[
temp
].
uvr
;
discomfort
=
rows
[
temp
].
discomfort
;
heat
=
rows
[
temp
].
heat
;
sensibleTem
=
rows
[
temp
].
sensibleTem
;
windSpeed
=
rows
[
temp
].
windSpeed
;
presentTem
=
rows
[
temp
].
presentTem
;
skyState
=
rows
[
temp
].
skyState
;
rainfall
=
rows
[
temp
].
rainfall
;
typhoon
=
rows
[
temp
].
typhoon
;
lightning
=
rows
[
temp
].
lightning
;
}
})
deathProb
=
uvr
+
discomfort
+
heat
+
sensibleTem
+
windSpeed
+
presentTem
+
skyState
+
rainfall
+
typhoon
+
lightning
;
sql
=
'INSERT INTO kkonzi_test.deathProb (prob) VALUES (?)'
;
var
params
=
deathProb
;
db
.
query
(
sql
,
function
(
err
,
rows
,
fields
){
if
(
err
)
{
console
.
log
(
err
);
}
else
{
console
.
log
(
'Success!'
);
}
}
})
res
.
render
(
'index'
,
{
title
:
'Express'
});
});
...
...
Please
register
or
login
to post a comment