-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_db.js
More file actions
18 lines (14 loc) · 749 Bytes
/
check_db.js
File metadata and controls
18 lines (14 loc) · 749 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import Database from 'better-sqlite3'
const db = new Database('./server/data/data.db')
console.log('Tables and Row Counts:')
const tables = db.prepare("SELECT name FROM sqlite_master WHERE type='table'").all()
tables.forEach(t => {
const count = db.prepare(`SELECT COUNT(*) as cnt FROM ${t.name}`).get()
console.log(` - ${t.name}: ${count.cnt} rows`)
})
console.log('\nMakeup Classes Sample:')
const makeup = db.prepare('SELECT id_makeup, status, teacher_id, section_id FROM makeup_classes LIMIT 5').all()
console.log(JSON.stringify(makeup, null, 2))
console.log('\nTeachers Sample:')
const teachers = db.prepare('SELECT id_teacher, prefix, first_name, last_name FROM teachers LIMIT 3').all()
console.log(JSON.stringify(teachers, null, 2))