forked from sethmiles/movieDB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreateDB.rb
executable file
·73 lines (67 loc) · 2.69 KB
/
createDB.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
65
66
67
68
69
70
71
72
73
require 'mysql'
def create_table(con, tableName)
con.query("DROP TABLE IF EXISTS #{tableName}")
con.query("CREATE TABLE IF NOT EXISTS \
#{tableName}( Id INT PRIMARY KEY AUTO_INCREMENT, \
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, \
created_at VARCHAR(255), \
rotten_id INT(11), \
imdb_id INT(11), \
status VARCHAR(255), \
title VARCHAR(255), \
year INT(11), \
mpaa_rating VARCHAR(255), \
runtime INT(11), \
theater_release VARCHAR(255), \
dvd_release VARCHAR(255), \
digital_release VARCHAR(255), \
rotten_tomatoes_critics_rating VARCHAR(255), \
rotten_tomatoes_critics_score VARCHAR(255), \
rotten_tomatoes_audience_score VARCHAR(255), \
metascore VARCHAR(255), \
imdb_rating VARCHAR(255), \
synopsis TEXT, \
artwork VARCHAR(255), \
thumbnail VARCHAR(255), \
directors VARCHAR(255), \
writers VARCHAR(255), \
budget VARCHAR(255), \
genres VARCHAR(255), \
limited VARCHAR(255), \
actors TEXT, \
trailer_link VARCHAR(255), \
trailer_checked VARCHAR(255), \
imdb_link VARCHAR(255), \
cast_1 VARCHAR(255), \
cast_2 VARCHAR(255), \
cast_3 VARCHAR(255), \
cast_4 VARCHAR(255))")
end
def createReviewTable(con, tableName)
con.query("DROP TABLE IF EXISTS #{tableName}")
con.query("CREATE TABLE IF NOT EXISTS \
#{tableName}( Id INT PRIMARY KEY AUTO_INCREMENT, \
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, \
review_id VARCHAR(255), \
rotten_id INT(11), \
date VARCHAR(255), \
critic VARCHAR(255), \
freshness VARCHAR(255), \
publication VARCHAR(255), \
quote TEXT, \
original_score VARCHAR(255), \
full_review_link VARCHAR(255))")
end
def createUpdateTable(con)
con.query("CREATE TABLE IF NOT EXISTS \
UpdateRecords(Id INT PRIMARY KEY AUTO_INCREMENT, \
date TIMESTAMP DEFAULT CURRENT_TIMESTAMP, \
message TEXT)")
end
con = Mysql.new 'localhost', 'registf6_movies', 'o7_r7S{(_-Rp', 'registf6_myMovies'
create_table(con, "Movies")
create_table(con, "MovieArchives")
createReviewTable(con, "Reviews")
createReviewTable(con, "ReviewArchives")
createUpdateTable(con)
con.close()