28 lines
727 B
JavaScript
28 lines
727 B
JavaScript
const Database = require('better-sqlite3');
|
|
const path = require('path');
|
|
const fs = require('fs');
|
|
|
|
const dbPath = path.join(__dirname, 'data', 'ebay_items.db');
|
|
|
|
if (!fs.existsSync(dbPath)) {
|
|
console.error(`Database not found at: ${dbPath}`);
|
|
process.exit(1);
|
|
}
|
|
|
|
const db = new Database(dbPath);
|
|
|
|
try {
|
|
console.log('Truncating items table...');
|
|
const result = db.prepare('DELETE FROM items').run();
|
|
console.log(`Success! Deleted ${result.changes} items.`);
|
|
|
|
// Optional: vacuum the database to reclaim space
|
|
console.log('Vacuuming database...');
|
|
db.exec('VACUUM');
|
|
console.log('Vacuum complete.');
|
|
} catch (err) {
|
|
console.error('Error truncating items table:', err.message);
|
|
} finally {
|
|
db.close();
|
|
}
|