Closedown

This commit is contained in:
2019-04-02 13:12:00 +02:00
parent ac69f7d671
commit ab7341ee40
+23 -32
View File
@@ -2,37 +2,27 @@ import java.sql.DriverManager as DriverManager
import java.sql.ResultSet as ResultSet import java.sql.ResultSet as ResultSet
import java.util.Properties as Properties import java.util.Properties as Properties
Class.forName("org.relique.jdbc.csv.CsvDriver"); stmt = None
db = os.path.abspath(get_context().setup.expandPath("{home}/statistics"))
props = Properties() def get_stats_connection():
props.put("fileExtension", ".csv") global stmt
props.put("separator", ";") Class.forName("org.relique.jdbc.csv.CsvDriver");
props.put("timestampFormat", "dd/MM/yy HH:mm:ss.SSS") db = os.path.abspath(get_context().setup.expandPath("{home}/statistics"))
#timestampFormat, timeFormat, dateFormat props = Properties()
props.put("indexedFiles", "true"); props.put("fileExtension", ".csv")
props.put("fileTailPattern", "(\\d+)_(\\d+)"); #props.put("fileTailPattern", "-(\\d+)_(\\d+)"); props.put("separator", ";")
props.put("fileTailParts", "Year,Month"); props.put("timestampFormat", "dd/MM/yy HH:mm:ss.SSS")
#Command,Args,Source,Start,End,Background,Result,Return #timestampFormat, timeFormat, dateFormat
props.put("columnTypes", "String,String,String,Timestamp,Timestamp,Boolean,String,String"); props.put("indexedFiles", "true");
conn = DriverManager.getConnection("jdbc:relique:csv:" + db, props); props.put("fileTailPattern", "(\\d+)_(\\d+)"); #props.put("fileTailPattern", "-(\\d+)_(\\d+)");
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY); props.put("fileTailParts", "Year,Month");
#results = stmt.executeQuery("SELECT Command,Result FROM 2019_03"); #Command,Args,Source,Start,End,Background,Result,Return
#results = stmt.executeQuery("SELECT Command,Result,Year,Month FROM Test"); props.put("columnTypes", "String,String,String,Timestamp,Timestamp,Boolean,String,String");
""" conn = DriverManager.getConnection("jdbc:relique:csv:" + db, props);
results = stmt.executeQuery("SELECT Command,Result,Year,Month, Start FROM ."); stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
#results = stmt.executeQuery("SELECT Command,Result FROM 2019_03");
#Command,Args,Source,Start,End,Background,Result,Return #results = stmt.executeQuery("SELECT Command,Result,Year,Month FROM Test");
return conn
if results.last():
print("Command= " + results.getString("Command") + " Result= " + results.getString("Result"))
if (results.first()):
print("Command= " + results.getString("Command") + " Result= " + results.getString("Result"))
results = stmt.executeQuery("SELECT Command,Result,Start FROM . WHERE Result = 'success'")
while results.next():
print("Command= " + results.getString("Command") + " Result= " + results.getString("Result"))
"""
def _get_count(sql): def _get_count(sql):
ret = 0 ret = 0
@@ -122,10 +112,11 @@ def print_stats(start = None, end = None):
print "-----------------------------------------------------------" print "-----------------------------------------------------------"
conn = get_stats_connection()
start= "06/02/19" #"06/02/19 13:27:56.124" start= "06/02/19" #"06/02/19 13:27:56.124"
end= "16/03/19" #"29/04/19 13:27:56.124" end= "16/03/19" #"29/04/19 13:27:56.124"
print_stats(start, end) print_stats(start, end)
print_cmd_stats ("%test1.py", start, end) print_cmd_stats ("%test1.py", start, end)
conn.close() conn.close()