Showing
1 changed file
with
26 additions
and
0 deletions
db.js
0 → 100644
1 | +const mysql = require('mysql'); | ||
2 | +const cnf = require('/cnf.js').AWSMYSQL | ||
3 | + | ||
4 | +const pool = mysql.createPool({ | ||
5 | + connectionLimit : cnf.connectionLimit, | ||
6 | + host : cnf.host, | ||
7 | + user : cnf.user, | ||
8 | + password : cnf.password, | ||
9 | + database : cnf.database | ||
10 | +}); | ||
11 | + | ||
12 | +exports.getLngLat = (fail, done) => { | ||
13 | + pool.getConnection((err, conn) => { | ||
14 | + if(err) { | ||
15 | + return fail(err); | ||
16 | + } | ||
17 | + let sql = 'SELECT * FROM test'; | ||
18 | + conn.query(sql, (err, rows) => { | ||
19 | + if(err) { | ||
20 | + return fail(err); | ||
21 | + } | ||
22 | + conn.release(); | ||
23 | + done(rows); | ||
24 | + }); | ||
25 | + }); | ||
26 | +} |
-
Please register or login to post a comment