35 lines
782 B
JavaScript
35 lines
782 B
JavaScript
// db.js
|
|
const sqlite3 = require('sqlite3').verbose();
|
|
const path = require('path');
|
|
|
|
const db = new sqlite3.Database(path.join(__dirname, 'db', 'memory.db'), (err) => {
|
|
if (err) {
|
|
console.error('[DB] Connection error:', err.message);
|
|
} else {
|
|
console.log('[DB] Connected to SQLite database.');
|
|
}
|
|
});
|
|
|
|
db.serialize(() => {
|
|
db.run(`
|
|
CREATE TABLE IF NOT EXISTS memory (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
label TEXT UNIQUE,
|
|
data TEXT
|
|
)
|
|
`);
|
|
|
|
db.run(`
|
|
CREATE TABLE IF NOT EXISTS tasks (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
action TEXT,
|
|
parameters TEXT,
|
|
context TEXT,
|
|
outcome TEXT,
|
|
score INTEGER DEFAULT 0
|
|
)
|
|
`);
|
|
});
|
|
|
|
module.exports = db;
|