import Database from 'better-sqlite3'; import { dirname, join } from 'path'; import { fileURLToPath } from 'url'; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); console.log('Testing better-sqlite3 database...'); console.log('Node version:', process.version); try { const dbPath = join(__dirname, '../temp/test.db'); console.log('Creating database at:', dbPath); const db = new Database(dbPath); console.log('✅ Database created successfully'); db.exec('CREATE TABLE IF NOT EXISTS test (id INTEGER PRIMARY KEY, name TEXT)'); console.log('✅ Table created successfully'); const stmt = db.prepare('INSERT INTO test (name) VALUES (?)'); stmt.run('test entry'); console.log('✅ Data inserted successfully'); const result = db.prepare('SELECT * FROM test').all(); console.log('✅ Query executed successfully:', result); db.close(); console.log('✅ Database closed successfully'); console.log('\n✨ All database operations successful!'); } catch (error) { console.error('❌ Database error:', error); process.exit(1); }