cletus/bot/db.js
roberts 2a9f9159bd
All checks were successful
Deploy Cletus Bot / deploy (push) Successful in 26s
Massive Overhaul. Added state machine.
2025-05-10 12:24:59 -05:00

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;