class SqliteDataExporter implements DataExporter {

    @Override
    public void export(final StoreLoader loader,
                       final Path output,
                       final String username,
                       final String password) throws SQLException, IOException {

        final String connectionString = "jdbc:sqlite:" + output.toString();

        final List<String> createTableStatements = Stream.of(getClass().getResourceAsStream(CREATE_TABLE_RESOURCE))
            .map(InputStreamReader::new)
            .map(BufferedReader::new)
            .flatMap(BufferedReader::lines)
            .collect(Collectors.toList());

        try (Connection conn = DriverManager.getConnection(connectionString, username, password)) {

            try (Statement stmt = conn.createStatement()) {
                for (final String createTable : createTableStatements) {
                    stmt.executeUpdate(createTable);
                }
            }

            try (PreparedStatement insertStatement = conn.prepareStatement(INSERT_ROW)) {
                DataEntry next;
                while ((next = loader.nextEntry()) != null) {
                    try (InputStream data = next.getValue()) {
                        insertStatement.setBytes(1, next.getKey());
                        insertStatement.setBytes(2, IOUtils.toByteArray(data));
                        insertStatement.execute();
                    }
                }
            }

        }

    }

}