-
Notifications
You must be signed in to change notification settings - Fork 0
/
reports.rb
64 lines (31 loc) · 874 Bytes
/
reports.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
require "amalgalite"
class Report #report class
def initialize(table_to_analyze, db_handler)
@table_to_analyze = table_to_analyze
@db = db_handler.db
end
def get_books_by_title(title)
i = 0
@db.execute("SELECT title FROM #{@table_to_analyze} WHERE title='#{title}'") do |n|
i += 1
end
puts "There are #{i} sales with title '#{title}'"
end
def get_books_by_isbn_asin(isbn_asin)
i = 0
@db.execute("SELECT ean FROM #{@table_to_analyze} WHERE ean='#{isbn_asin}'") do |n|
i += 1
end
puts "There are #{i} sales with the ISBN/ASIN '#{isbn_asin}'"
end
end
# def get_books_with_title(title)
# db.execute("SELECT title FROM sample1 WHERE title='#{title}'")
# i = 0
# @table.each do |row|
# if (row.title == title)
# i += 1
# end
# end
# puts "There are #{i} books with title '#{title}'"
# end