From 798125e645853c11d22cfa18169b4cce9e3fb1bb Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Mon, 19 Oct 2020 17:14:56 +0100 Subject: [PATCH] csv conversion tool --- .../com/muwire/core/hostcache/DB2CSV.groovy | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 core/src/main/groovy/com/muwire/core/hostcache/DB2CSV.groovy diff --git a/core/src/main/groovy/com/muwire/core/hostcache/DB2CSV.groovy b/core/src/main/groovy/com/muwire/core/hostcache/DB2CSV.groovy new file mode 100644 index 00000000..19b3be25 --- /dev/null +++ b/core/src/main/groovy/com/muwire/core/hostcache/DB2CSV.groovy @@ -0,0 +1,26 @@ +package com.muwire.core.hostcache + +import groovy.sql.Sql +import net.i2p.data.Destination + +class DB2CSV { + + static void main(args) { + File h2 = new File(System.getProperty("user.home")) + h2 = new File(h2, ".MuWire") + h2 = new File(h2, "h2") + + def db = [ url : "jdbc:h2:" + h2.getAbsolutePath(), + user : "muwire", + password : "", + driver : "org.h2.Driver" ] + def sql = Sql.newInstance(db.url, db.user, db.password, db.driver) + + sql.eachRow("select * from HOST_ATTEMPTS") { + Destination dest = new Destination(it.DESTINATION) + println "${dest.toBase32()},$it.TSTAMP,$it.STATUS" + } + + sql.close() + } +}