const initSqlJs = require('sql.js');
const fs = require('fs');

initSqlJs().then(SQL => {
    const buffer = fs.readFileSync('E:/var/lib/9router/db/data.sqlite');
    const db = new SQL.Database(buffer);
    
    // Get all provider connections with full data
    const connections = db.exec("SELECT id, data FROM providerConnections");
    if (connections[0]?.values) {
        connections[0].values.forEach(row => {
            const data = JSON.parse(row[1]);
            console.log(`\n--- Connection: ${row[0]} ---`);
            console.log(JSON.stringify(data, null, 2));
        });
    }
    
    db.close();
    process.exit(0);
});
