-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdump_db.dart
More file actions
32 lines (25 loc) · 960 Bytes
/
dump_db.dart
File metadata and controls
32 lines (25 loc) · 960 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import 'dart:io';
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
import 'package:path/path.dart';
void main() async {
sqfliteFfiInit();
databaseFactory = databaseFactoryFfi;
final userProfile = Platform.environment['USERPROFILE'];
final dbPath = join(userProfile!, 'Documents', 'schedule_history.db');
print("Opening DB at $dbPath");
try {
final db = await databaseFactory.openDatabase(dbPath);
final countResult = await db.rawQuery('SELECT COUNT(*) FROM power_events');
final count = countResult.first.values.first as int;
print("Total events: $count");
final events = await db.query('power_events', orderBy: 'timestamp ASC');
print("\n--- Power Events ---");
for (var e in events) {
print(
"ID: ${e['id']} | Status: ${e['status']} | TS: ${e['timestamp']} | Manual: ${e['is_manual']} | Key: ${e['firebase_key']}");
}
await db.close();
} catch (e) {
print("Error: $e");
}
}