31 lines
899 B
JavaScript
31 lines
899 B
JavaScript
|
|
const sqlite3 = require('sqlite3').verbose();
|
||
|
|
|
||
|
|
let db = new sqlite3.Database('playdb.sqlite3', sqlite3.OPEN_READWRITE, (err) => {
|
||
|
|
if (err) {
|
||
|
|
console.error("ERROR: opening DB failed: ", err.message);
|
||
|
|
}
|
||
|
|
console.log('Connected.');
|
||
|
|
});
|
||
|
|
|
||
|
|
db.serialize(() => {
|
||
|
|
db.each('select * from option', (err, row) => {
|
||
|
|
if (err) {
|
||
|
|
console.error("ERROR: fetching data: ", err.message);
|
||
|
|
}
|
||
|
|
console.log(row.ID + "\t" + row.PutCall);
|
||
|
|
});
|
||
|
|
db.run('insert into Log (Message) values (\'' + new Date().toUTCString() + '\')', (err) => {
|
||
|
|
if (err) {
|
||
|
|
console.error("ERROR: inserting row: ", err.message);
|
||
|
|
}
|
||
|
|
console.log('Log-Row inserted');
|
||
|
|
});
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
db.close((err) => {
|
||
|
|
if (err) {
|
||
|
|
console.error("ERROR: closing DB: ", err.message);
|
||
|
|
}
|
||
|
|
console.log('DB Connection closed');
|
||
|
|
})
|