-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi_extractor_config.py
More file actions
150 lines (131 loc) · 5.83 KB
/
api_extractor_config.py
File metadata and controls
150 lines (131 loc) · 5.83 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
from sqlalchemy import *
DEBUG = False
# ***************************************************************************
# > BE VERY CAREFUL ABOUT CREATE_TABLES.
# > WHEN SET TO TRUE IT WILL DROP ALL THE EXISTING TABLES AND CREATES NEW ONES.
# ***************************************************************************
CREATE_TABLES = False
DATETIME_FORMAT = "%Y-%m-%d %H:%M:%S"
DATE_FORMAT = "%Y-%m-%d"
HASHTAGS_BUFFER_DB = 'hashtags'
DATA_FOLDER = 'persistent_data'
SCHEMA_NAME = 'imports'
#-----------------------------------------------------------------------
# NOTE ON SCHEMAS:
# The schemas are wrapped inside a function, so that every time the function
# is called we get a new set of Column objects.
#
# This is needed for the 'retry a few times' feature, when we create the
# tableclass multiple times. I am not exactlu sure why.
#-----------------------------------------------------------------------
#-----------------------------------------------------------------------
# Twitter Table Schemas
#-----------------------------------------------------------------------
def twitter_account_schema():
twitter_account_schema = {
'Extract_Datetime': Column(String(length=30)),
'Account_ID': Column(String(length=30)),
'Display_Name': Column(String(length=100)),
'Handle': Column(String(length=30)),
'Statuses_Count': Column(Integer()),
'Followers_Count': Column(Integer()),
'Friends_Count': Column(Integer()),
'Favourites_Count': Column(Integer()),
'Listed_Count': Column(Integer()),
'Profile_URL': Column(String(length=300)),
'Profile_Image': Column(String(length=300)),
'Banner_Image': Column(String(length=300)),
'Location': Column(String(length=100)),
'Timezone': Column(String(length=50)),
'Description': Column(String(length=400)),
'Daily_Mentions_Count': Column(Integer()),
'Autogen_ID': Column(Integer(), primary_key=True),
'__tablename__': 'twitter_account_stats',
'__table_args__': {'schema' : SCHEMA_NAME}
}
return twitter_account_schema
def twitter_status_schema():
twitter_status_schema = {
'Extract_Datetime': Column(String(length=30)),
'Tweet_ID': Column(String(length=30)),
'Created_Date': Column(String(length=30)),
'Handle': Column(String(length=30)),
'Tweet_Text': Column(String(length=700)),
'Favourite_Count': Column(Integer()),
'Retweet_Count': Column(Integer()),
'Hashtags': Column(String(length=100)),
'Media': Column(String(length=3000)),
'URLs': Column(String(length=500)),
'Place': Column(String(length=500)),
'User_Mentions': Column(String(length=5000)),
'Favorited': Column(String(length=20)),
'Retweeted': Column(String(length=20)),
'In_reply_to_screen_name': Column(String(length=30)),
'Autogen_ID': Column(Integer(), primary_key=True),
'__tablename__': 'twitter_statuses',
'__table_args__': {'schema' : SCHEMA_NAME}
}
return twitter_status_schema
# For the mssql table
def twitter_hashtags_schema():
twitter_hashtags_schema = {
'Extract_Datetime': Column(String(length=30)),
'TweetID': Column(String(length=30)),
'TweetText': Column(String(length=700)),
'AccountID': Column(String(length=30)),
'DisplayName': Column(String(length=100)),
'Handle': Column(String(length=30)),
'CreatedAt': Column(String(length=30)),
'Hashtags': Column(String(length=100)),
'Autogen_ID': Column(Integer(), primary_key=True),
'__tablename__': 'twitter_hashtags',
'__table_args__': {'schema' : SCHEMA_NAME}
}
return twitter_hashtags_schema
# For the sqlite buffer table
twitter_hashtags_sqlite_schema = [
('TweetID', 'text'),
('TweetText', 'text'),
('AccountID', 'text'),
('DisplayName', 'text'),
('Handle', 'text'),
('CreatedAt', 'text'),
('Hashtags', 'text')
]
#-----------------------------------------------------------------------
# Youtube Table Schemas
#-----------------------------------------------------------------------
def channel_table_schema():
channel_table_schema = {
'Extract_Datetime': Column(String(length=30)),
'channel_name': Column(String(length=200)),
'channel_id': Column(String(length=30)),
'total_comments': Column(String(length=30)),
'subscribers': Column(Integer()),
'new_subscribers': Column(Integer()),
'total_views': Column(String(length=30)),
'videos': Column(Integer()),
'Autogen_ID': Column(Integer(), primary_key=True), # add a PK - SQLAlchemy demands this
'__tablename__': 'youtube_channel_stats', #tablename assignment is done inside the dictionary
'__table_args__': {'schema' : SCHEMA_NAME}
}
return channel_table_schema
def videos_table_schema():
videos_table_schema = {
'Extract_Datetime': Column(String(length=30)),
'publishedAt': Column(String(length=30)),
'video': Column(String(length=50)),
'title': Column(String(length=200)),
'likes': Column(Integer()),
'dislikes': Column(Integer()),
'comments': Column(Integer()),
'shares': Column(Integer()),
'views': Column(Integer),
'averageViewDuration': Column(Integer),
'subscribersGained': Column(Integer),
'subscribersLost': Column(Integer),
'Autogen_ID': Column(Integer(), primary_key=True), # add a PK - SQLAlchemy demands this
'__tablename__': 'youtube_videos_stats', #tablename assignment is done inside the dictionary
'__table_args__': {'schema' : SCHEMA_NAME}
}
return videos_table_schema