-
-
Save sixtyfive/113e133781ce5860b31f798ff4e81787 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cp /var/lib/misc/throughput/data.sqlite3 /tmp/ ; sqlite3 /tmp/data.sqlite3 'SELECT * FROM data WHERE timestamp BETWEEN "2020-10-26 07:00:06" AND "2020-10-26 08:00:06"' | wc -l | |
192 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
["2020-10-26 07:00:06", "2020-10-26 08:00:06"] | |
#<SQLite3::ResultSet:0x000055843a614928 | |
@db= | |
#<SQLite3::Database:0x000055843a6157b0 | |
@authorizer=nil, | |
@busy_handler=nil, | |
@collations={}, | |
@encoding=nil, | |
@functions={}, | |
@readonly=false, | |
@results_as_hash=nil, | |
@tracefunc=nil, | |
@type_translation=nil, | |
@type_translator= | |
#<Proc:0x000055843a6212b8 /usr/lib/ruby/gems/2.7.0/gems/sqlite3-1.4.2/lib/sqlite3/database.rb:722 (lambda)>>, | |
@stmt= | |
#<SQLite3::Statement:0x000055843a614f68 | |
@columns=nil, | |
@connection= | |
#<SQLite3::Database:0x000055843a6157b0 | |
@authorizer=nil, | |
@busy_handler=nil, | |
@collations={}, | |
@encoding=nil, | |
@functions={}, | |
@readonly=false, | |
@results_as_hash=nil, | |
@tracefunc=nil, | |
@type_translation=nil, | |
@type_translator= | |
#<Proc:0x000055843a6212b8 /usr/lib/ruby/gems/2.7.0/gems/sqlite3-1.4.2/lib/sqlite3/database.rb:722 (lambda)>>, | |
@remainder="", | |
@results=#<SQLite3::ResultSet:0x000055843a614928 ...>, | |
@types=nil>> | |
[76517, "2020-10-26 07:00:06", 0.035311381022135414, 0.0088653564453125] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sqlite3' | |
TIME_FORMAT = '%F %T' | |
task :create_graph do | |
db = SQLite3::Database.new('file:///var/lib/misc/throughput/data.sqlite3?mode=ro') | |
t2 = Time.now | |
t1 = t2 - 1*60**2 | |
t2 = t2.strftime(TIME_FORMAT) | |
t1 = t1.strftime(TIME_FORMAT) | |
p [t1, t2] | |
qry = db.prepare("SELECT * FROM data WHERE timestamp BETWEEN ? AND ?") | |
qry.bind_params(t1, t2) | |
res = qry.execute | |
pp res | |
res.each{|row| p row} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment