From 6df15baa3dca54e263e3f4aedaae2f5ec3b6abfe Mon Sep 17 00:00:00 2001 From: 5hseok Date: Mon, 8 Jul 2024 14:17:47 +0900 Subject: [PATCH] =?UTF-8?q?Revert=20"=E2=9C=A8=20[FEAT]=20DB=EC=9D=98=20?= =?UTF-8?q?=EC=A3=BC=EC=86=8C=20=EA=B2=B0=EC=B8=A1=EC=B9=98=EB=A5=BC=20?= =?UTF-8?q?=EC=B1=84=EC=9A=B0=EB=8A=94=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 1dcca8049102f65fdc36c67e9221a1a9bcbf8c28. --- .../transpose_location_to_address.py | 48 +------------------ 1 file changed, 2 insertions(+), 46 deletions(-) diff --git a/RoomCatcher_Data_AI/dataAnalyze/transpose_location_to_address.py b/RoomCatcher_Data_AI/dataAnalyze/transpose_location_to_address.py index 0db874a..adfb7bf 100755 --- a/RoomCatcher_Data_AI/dataAnalyze/transpose_location_to_address.py +++ b/RoomCatcher_Data_AI/dataAnalyze/transpose_location_to_address.py @@ -14,7 +14,7 @@ def get_address_from_coordinates(x, y, API_KEY): if response.status_code == 200: data = response.json() if data['response']['status'] == 'OK': - return data['response']['result'][0]['text'] # return data['response']['result'][1]['text'] 로 하면 도로명 주소가 나옴 + return data['response']['result'][0]['text'] return None def get_secret(setting, secrets): @@ -101,50 +101,6 @@ def transpose_location_to_address(): # 연결 종료 cursor.close() connection.close() - -def update_missing_addresses(): - base_dir = os.path.dirname(os.path.abspath(__file__)) - secret_file = os.path.join(base_dir, '..', '..','secret.json') - - with open(secret_file) as f: - secrets = json.loads(f.read()) - - # API 키 설정 - API_KEY = get_secret('API_KEY', secrets) - - # SQLite3 데이터베이스 연결 - connection = sqlite3.connect('room_lists.db') - cursor = connection.cursor() - - try: - # 결측치가 있는 레코드 선택 - cursor.execute("SELECT id, location FROM room_lists WHERE address IS NULL OR address = ''") - rows = cursor.fetchall() - - # 결측치 주소 업데이트 - for row in rows: - row_id, location = row - location = json.loads(location) - x, y = location[0], location[1] - address = get_address_from_coordinates(x, y, API_KEY) - if address: - cursor.execute("UPDATE room_lists SET address = ? WHERE id = ?", (address, row_id)) - - # 변경사항 커밋 - connection.commit() - except sqlite3.Error as err: - print(f"Error: {err}") - # 오류가 발생하면 롤백 - connection.rollback() - finally: - # 연결 종료 - cursor.close() - connection.close() - - print("Missing addresses have been updated.") if __name__ == '__main__': - update_missing_addresses() - -# if __name__ == '__main__': -# transpose_location_to_address() \ No newline at end of file + transpose_location_to_address() \ No newline at end of file