package de.roko.genalogy.downloader.database;

import java.sql.*;

public class ArchiveReader {

    private static final String DB_FILE = "archion.db";

    public static void printAllArchives() {
        String sql = "SELECT id, bundesland, name, link FROM archive ORDER BY bundesland, name";

        try (Connection conn = DriverManager.getConnection("jdbc:sqlite:" + DB_FILE);
             Statement stmt = conn.createStatement();
             ResultSet rs = stmt.executeQuery(sql)) {

            while (rs.next()) {
                int id = rs.getInt("id");
                String bundesland = rs.getString("bundesland");
                String name = rs.getString("name");
                String link = rs.getString("link");

                System.out.printf("ID: %-3d | %-20s | %-60s | %s%n", id, bundesland, name, link);
            }

        } catch (SQLException e) {
            System.err.println("❌ Fehler beim Lesen aus der Datenbank: " + e.getMessage());
        }
    }
}
