-
Notifications
You must be signed in to change notification settings - Fork 1
/
database.js
44 lines (34 loc) · 977 Bytes
/
database.js
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
44
const sqlite = require("sqlite3")
class Database {
db;
connectToDatabase = () => {
this.db = new sqlite.Database('./db/teamsBot.db', (err) => {
if (err) {
console.error(err.message);
}
});
}
closeDatabaseConnection = () => {
this.db.close((err) => {
if (err) {
console.error(err.message);
}
});
}
createTable = () => {
this.db.run('CREATE TABLE timetable(class text, start_time text, end_time text, day text)');
}
viewTimeTable = () => {
this.connectToDatabase()
let sql = `SELECT * from timetable`;
this.db.all(sql, [], (err, rows) => {
rows.forEach(row => {
console.log(row);
});
});
this.closeDatabaseConnection()
}
insertIntoTimeTable(){
}
}
module.exports = Database