Class: Aspera::Sync::Database
- Inherits:
-
Object
- Object
- Aspera::Sync::Database
- Defined in:
- lib/aspera/sync/database.rb
Overview
Access async sqlite database
Instance Method Summary collapse
- #counters(sql_suffix = nil) ⇒ Object
- #execute(sql) ⇒ Object
- #file_info(sql_suffix = nil) ⇒ Object
-
#initialize(db_path) ⇒ Database
constructor
A new instance of Database.
- #meta(sql_suffix = nil) ⇒ Object
- #overview ⇒ Object
Constructor Details
#initialize(db_path) ⇒ Database
Returns a new instance of Database.
67 68 69 |
# File 'lib/aspera/sync/database.rb', line 67 def initialize(db_path) @db = SqLite3Wrapper.new(db_path) end |
Instance Method Details
#counters(sql_suffix = nil) ⇒ Object
85 86 87 |
# File 'lib/aspera/sync/database.rb', line 85 def counters(sql_suffix = nil) @db.single_table('sync_snap_counters_table', sql_suffix) end |
#execute(sql) ⇒ Object
93 94 95 |
# File 'lib/aspera/sync/database.rb', line 93 def execute(sql) @db.execute(sql) end |
#file_info(sql_suffix = nil) ⇒ Object
89 90 91 |
# File 'lib/aspera/sync/database.rb', line 89 def file_info(sql_suffix = nil) @db.full_table('sync_snapdb_table', sql_suffix) end |
#meta(sql_suffix = nil) ⇒ Object
81 82 83 |
# File 'lib/aspera/sync/database.rb', line 81 def (sql_suffix = nil) @db.single_table('sync_snapmeta_table', sql_suffix) end |
#overview ⇒ Object
71 72 73 74 75 76 77 78 79 |
# File 'lib/aspera/sync/database.rb', line 71 def overview tables = @db.execute("SELECT name FROM sqlite_master WHERE type='table';") tables.flat_map do |table_row| table_name = table_row['name'] @db.execute("PRAGMA table_info(#{table_name});").map do |col| {'table' => table_name}.merge(col) end end end |