-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mysql_batch 폴더 추가 #15
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생많으셨습니다! csv가 조금씩 바뀌었어서, 한번씩 다시 보시고 반영해주시면 좋을 것 같아요 👍 👍
@@ -0,0 +1 @@ | |||
.DS_STORE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
mysql_batch/create_table.py
Outdated
|
||
create_table_restaurants = """ | ||
CREATE TABLE `restaurants` ( | ||
`restaurant_id` BIGINT NOT NULL AUTO_INCREMENT, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
restaurant_id -> id 로 변경 부탁드립니다.
table의 pk는 모두 id로 통일해주세요~
mysql_batch/create_table.py
Outdated
`review_count` BIGINT NOT NULL DEFAULT 0, | ||
`like_count` BIGINT NOT NULL DEFAULT 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
사소하지만 BIGINT 살짝 과한것 같습니다 ㅎㅎ INT로 해도 충분하겠습니다.
mysql_batch/create_table.py
Outdated
`review_count` BIGINT NOT NULL DEFAULT 0, | ||
`like_count` BIGINT NOT NULL DEFAULT 0, | ||
`address` VARCHAR(256), | ||
`contact_num` VARCHAR(32), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
contact_number 로 변경 부탁드립니다.
mysql_batch/create_table.py
Outdated
`contact_num` VARCHAR(32), | ||
`rating_avg` DOUBLE, | ||
`representative_image_url` TEXT, | ||
`kingo_pass` TINYINT, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kingo_pass -> discount_content 로 변경해주세요~ (varchar(100)
mysql_batch/create_table.py
Outdated
`representative_image_url` TEXT, | ||
`kingo_pass` TINYINT, | ||
`view_count` BIGINT DEFAULT 0, | ||
PRIMARY KEY (`restaurant_id`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-> id
mysql_batch/create_table.py
Outdated
create_table_restaurant_likes =""" | ||
CREATE TABLE `restaurant_likes` ( | ||
`id` BIGINT NOT NULL AUTO_INCREMENT, | ||
`restaurant_id` BIGINT NOT NULL, | ||
`user_name` VARCHAR(255) NOT NULL, | ||
PRIMARY KEY (`id`) | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8; | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여기서 좋아요 테이블을 만들고 삭제안해도 되지 않을까요?
mysql_batch/insert.py
Outdated
`contact_num`, | ||
`rating_avg`, | ||
`representative_image_url`, | ||
`kingo_pass`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
csv에 discount_content 추가되었으니 반영 부탁드립니다.
def insert_into_restaurants(cursor, restaurant): | ||
|
||
insert_query = """ | ||
INSERT INTO `restaurants` ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
menus 도 csv 추가되었으니 반영 부탁드립니다~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 폴더도 gitignore로 추가하고 제거해주세요~
mysql_batch/create_table_list.py
Outdated
CREATE TABLE IF NOT EXISTS `menus` ( | ||
`id` BIGINT NOT NULL AUTO_INCREMENT, | ||
`restaurant_id` BIGINT NOT NULL, | ||
`menu_name` VARCHAR(255) NOT NULL, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name이면 충분할 것 같아요~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
파일 2개만 지우고 머지하셔도 될 것 같습니다
고생하셨습니다! 👍
mysql_batch/read_csv.py
Outdated
csv_dict = csv.DictReader(file) | ||
for row in csv_dict: | ||
print(row) | ||
break |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
break? 테스트하다 남은걸까요?
def insert_into_categories(cursor, restaurant): | ||
|
||
insert_query = """ | ||
INSERT IGNORE INTO categories (restaurant_id, name) | ||
VALUES (%s, %s); | ||
""" | ||
|
||
cursor.execute(insert_query, ( | ||
restaurant['id'], | ||
restaurant['custom_category'] | ||
)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set으로 한번 category name을 걸러내고 insert 하는게 더 낫긴할텐데
몇건안되니까 지금도 괜찮긴합니다
mysql_batch/read_csv.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이거 파일 필요없어보이는데 지워주세요~
mysql_batch/restaurants.csv
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이것도 지워주세요~
기존 프로젝트 그대로 놔두고 mysql_batch 폴더만 추가하였습니다