Skip to content

Commit

Permalink
[KAN-000] naver review count, rating (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
sinkyoungdeok authored May 26, 2024
1 parent 1cf5b28 commit bf2b5f3
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 16 deletions.
1 change: 0 additions & 1 deletion mysql_batch/create_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ def create_table(cursor):
cursor.execute(delete_table_restaurants)
cursor.execute(delete_table_categories)
cursor.execute(delete_table_restaurant_categories)
cursor.execute(delete_table_operating_infos)
cursor.execute(delete_table_menus)

3 changes: 0 additions & 3 deletions mysql_batch/delete_table_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
delete_table_restaurant_categories = """
DELETE FROM `restaurant_categories`;
"""
delete_table_operating_infos= """
DELETE FROM `operating_infos`;
"""
delete_table_menus= """
DELETE FROM `menus`;
"""
11 changes: 7 additions & 4 deletions mysql_batch/insert.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ def insert_into_restaurants(cursor, restaurant):
`view_count`,
`discount_content`,
`longitude`,
`latitude`
`latitude`,
`naver_rating_avg`,
`naver_review_count`
)
VALUES (
%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s
%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s
);
"""

cursor.execute(insert_query, (
restaurant['id'],
restaurant['name'],
Expand All @@ -33,7 +34,9 @@ def insert_into_restaurants(cursor, restaurant):
0,
restaurant['discount_content'],
restaurant['longitude'],
restaurant['latitude']
restaurant['latitude'],
0.0 if restaurant['rating'] == '' else float(restaurant['rating']),
int(restaurant['review_count'].replace('+', ''))
))


Expand Down
8 changes: 0 additions & 8 deletions mysql_batch/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,6 @@

conn.commit()

# Insert operating_infos
with open('../operations.csv', mode='r') as file:
csv_dict = csv.DictReader(file)
for operation in csv_dict:
insert_into_operating_infos(cursor, operation)

conn.commit()

# Insert menus
with open('../menus.csv', mode='r') as file:
csv_dict = csv.DictReader(file)
Expand Down

0 comments on commit bf2b5f3

Please sign in to comment.