-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase.js
More file actions
43 lines (34 loc) · 755 Bytes
/
database.js
File metadata and controls
43 lines (34 loc) · 755 Bytes
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
31
32
33
34
35
36
37
38
39
40
41
42
43
const sqlite = require('sqlite3');
const DATABASE_PATH = './data/ExyllianDB.db';
function open() {
return new sqlite.Database(DATABASE_PATH, sqlite.OPEN_READWRITE, (err) => {
if (err) return console.error(err.message);
console.log('Connected to Exyllian\'s database.');
});
}
function run(conn, sql, parameters) {
if (!conn) return false;
return conn.run(sql, parameters, (err) => {
if (err) {
console.error(err.message);
return false;
}
return true;
});
}
function close(conn) {
if (!conn) return false;
return conn.close((err) => {
if (err) {
console.error(err.message);
return false;
}
console.log('Closed connection to Exyllian\'s database.');
return true;
});
}
module.exports = {
open,
close,
run
}