안녕하세요 쿠케님! 현재 구현되어 있는 댓글 삭제 로직을 보면 1. 댓글 조회 2-1. 자식 댓글이 존재하면 deleted=true 로 변경 2-2. 자식 댓글이 존재하지 않으면 댓글을 물리 삭제하고, 부모 댓글을 재귀적으로 삭제 이렇게 구현되어 있는데요. 동시성 문제가 발생할 수 있겠다는 생각이 들었습니다! T1 삭제 트랜잭션 T2 답글 트랜잭션 ──────────────────────────────────────────── SELECT 부모 SELECT 자식 → 없음 SELECT 부모 → ACTIVE INSERT 답글 COMMIT DELETE 부모 COMMIT (제가 잘 분석한게 맞나 모르겠네요 ㅎㅎ) 물론 이렇게 꼬일 확률은 낮지만, 이런 케이스에 대해서는 select for update를 거는 것이 좋을지, 아니면 fk를 추가하여 정합성을 보장해줘야 할지, 쿠케님 의견을 묻고 싶습니다.
========================================= [질문 템플릿] 1. 강의 내용과 관련된 질문인가요? (예) 2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (모름) 3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예) [질문 내용] 안녕하세요. 궁금증이 생겨서 질문을 드립니다. 현재 시점(26.8) 에서 강의를 듣고 있는데요. pdf 을 보면, 시간 지남에 따라 assertEquals() 내용이 달라 지듯이, 그 동안 강의 에서 배운 assertj 의 assertThat().isEqualTo()나, 다른 방법 들이 있어서 어떤 것을 쓰는게 맞는지 몰라서 여쭈어 봅니다. 첫 번째는 assertEquals(), assertThat()이고 두번째는 assertThrows() , assertThatThrownBy() 입니다. 영한님 이라면 어떤 것들을 쓰실지 궁금합니다. 답변 부탁 드립니다.
안녕하세요, 강사님. Shape 클래스 실습을 진행한 결과물을 공유드립니다. 실습 내용을 바탕으로 도형의 크기를 부모 클래스에서 관리하고, 각 자식 클래스에서 기본 크기를 지정할 수 있도록 생성자를 구성해 보았습니다. 시간 괜찮으실 때 구현 방향에서 어색한 부분이나 개선하면 좋을 점이 있는지 간단히 봐주시면 감사하겠습니다. 또한 이번 실습에서 추가로 생각해 보면 좋을 내용이 있다면 함께 알려주시면 감사하겠습니다. 감사합니다. package java2_30; import java.util.Scanner; /** * 화면에 출력할 수 있는 도형의 공통 부모 클래스입니다. * * 현재 실습에서는 삼각형과 정사각형만 다루므로, * 가로와 세로를 구분하지 않고 하나의 size 값으로 크기를 관리합니다. */ abstract class Shape { private final int size; protected Shape(int size) { this.size = size; } protected final int getSize() { return size; } /** * 각 도형의 모양을 콘솔에 출력합니다. */ abstract void render(); } class Rectangle extends Shape { private static final int DEFAULT_SIZE = 4; public Rectangle() { this(DEFAULT_SIZE); } public Rectangle(int size) { super(size); } @Override public void render() { for (int i = 0; i < getSize(); i++) { for (int j = 0; j < getSize(); j++) { System.out.print("*\t"); } System.out.println(); } } } class Triangle extends Shape { private static final int DEFAULT_SIZE = 5; public Triangle() { this(DEFAULT_SIZE); } public Triangle(int size) { super(size); } @Override public void render() { for (int i = 0; i < getSize(); i++) { for (int j = 0; j <= i; j++) { System.out.print("*\t"); } System.out.println(); } } } class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.print("사각형은 0, 삼각형은 그 외 숫자를 입력하세요: "); int input = scanner.nextInt(); Shape shape; if (input == 0) { shape = new Rectangle(); } else { shape = new Triangle(); } shape.render(); scanner.close(); } }
강사님 안녕하세요, 좋은 강의 여러번 반복해서 잘 듣고 있습니다. 재고 감소와 비교했을때 차이점이 궁금하여 문의드립니다. 안녕하세요 강사님 이전 재고 관리 강의와 차이에 대해 궁금합니다. 이전 질문을 참고하였으나 추가로 더 궁금한게 있어서 문의드립니다. 재고 감소와 쿠폰 발급의 차이점이 너무 헷갈려서 정리하고 있습니다. 두 경우 모두 한정된 수량을 여러 요청이 동시에 차지한다는 점에서는 비슷해 보입니다. 그렇다면 쿠폰도 이벤트 테이블에 잔여 수량을 100개나 300개로 설정하고, 재고처럼 수량을 차감한 뒤 사용자 쿠폰을 생성하는 방식으로 구현할 수 있지 않을까요? 강의에서는 쿠폰 발급의 정합성을 위해서 전체 로직에 락을 걸 필요가 없다고 하셨는데, 그러면 반대로 재고 감소 같은 경우도 마찬가지로 재고 감소의 정합성을 위해 전체로직에 락을 걸 필요 없이 다른 방법으로 하는게 더 나은 방법 아닌가요?? 비슷해 보이는 한정 수량 문제를 서로 다르게 푼 이유를 잘 모르겠습니다 ㅠㅠ
import asyncio import timeit from urllib.request import urlopen from concurrent.futures import ThreadPoolExecutor import threading # 실행 시작 시간 start =timeit.default_timer() # 서비스 방향이 비슷한 사이트로 실습권장(예 게시판 성 커뮤니티) urls = ['https://daum.net', 'https://naver.com', 'http://mlbpark.donga.com', 'https://tistory.com'] async def fetch(url, executor): # 실행 res = await loop.get_running_loop(executor, urlopen, url) # 결과 반환 return res.read()[0:5] async def main(): # 쓰레드 풀 생성 executor = ThreadPoolExecutor(max_workers=10) # future 객체 모아서 gather 에서 실행 futures = [ asyncio.ensure_future(fetch(url, executor)) for url in urls ] # 결과 취합 rst = await asyncio.gather(futures) print('------------------------------') print(('Result :', rst)) if __name__ == '__main__': # 루프 초기화 asyncio.run(main()) # 수행 시간 계산 duration = timeit.default_timer() - start # 총 실행 시간 print('Total Running Time :', duration) 여기에서 loop is not defined라고 나오네요 지금 파이선은 3.14버전을 쓰고있는데 저기 loop를 무엇으로 바꾸면 될지 모르겠어요
몽고 DB 접속 중인데요 강의내용 같이 mongodb+srv://admin:qwe123!!@cluster0.ic4ilij.mongodb.net/react_blog?retryWrites=true&w=majority&appName=Cluster0 하고 Connection whit Conection String "Connect"를 누르면 Unable to connect: querySrv ENOTFOUND mongodb. tcp.cluster0.ic4ilij.mongodb.net 라는 메시지와 함께 접속이 안되고 있습니다. 원인과 해결 방안을 여쭤 봅니다. -- 감사합니다.
강사님 답변처럼 SUPABASE_SERVICE_ROLE_KEY 복사하고 붙인 후 실행 했는데도 아래처럼 나오네요. 무시하고 계속 수업 진도를 나갈려고 하는데 내가 워낙 쌩 초보라 13번째 강의에서도 또 언급되길래 계속 무시하고 수업을 끝까지 들으면 해결 할 수 있는지 의심스럽습니다. 그리고 localhost:8000/docs 가 강사님 처럼 열리지 않네요... ㅠㅠ "사이트에 연결할 수 없음. localhost에서 연결을 거부했습니다"라고 하네요 PS C:\박영준\banbu-stocktrading-final> python run.py ⚠ SUPABASE_SERVICE_ROLE_KEY 미설정 - anon 키 사용 중. RLS가 켜져 있으면 쓰기가 차단될 수 있 습니다. Supabase URL: https://fohjixoviclcuwdtadxf.supabase.co INFO: Started server process [23136] INFO: Waiting for application startup. 서비스 시작 시 경제 데이터 수집을 즉시 실행합니다... 경제 지표 및 주가 데이터 업데이트 작업 시작... 2026-07-27 16:39:01,751 - httpx - INFO - HTTP Request: GET https://fohjixoviclcuwdtadxf.supabase.co/rest/v1/economic_and_stock_data?select=%EB%82%A0%EC%A7%9C&order=%EB%82%A0%EC%A7%9C.desc&limit=1 "HTTP/2 403 Forbidden" 마지막 수집 날짜 조회 중 오류 발생: {'message': 'permission denied for table economic_and_stock_data', 'code': '42501', 'hint': 'Grant the required privileges to the current role with: GRANT SELECT ON public.economic_and_stock_data TO service_role;', 'details': None} 2026-07-27 16:39:01,798 - httpx - INFO - HTTP Request: GET https://fohjixoviclcuwdtadxf.supabase.co/rest/v1/economic_and_stock_data?select=%2A&%EB%82%A0%EC%A7%9C=eq.2005-12-31 "HTTP/2 403 Forbidden" 경제 데이터 업데이트 중 오류 발생: {'message': 'permission denied for table economic_and_stock_data', 'code': '42501', 'hint': 'Grant the required privileges to the current role with: GRANT SELECT ON public.economic_and_stock_data TO service_role;', 'details': None} Traceback (most recent call last): File "C:\박영준\banbu-stocktrading-final\app\services\economic_ service.py ", line 134, in update_economic_data_in_background prev_data_response = supabase.table("economic_and_stock_data").select("*").eq("날짜", previous_date).execute() ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^ File "C:\Users\박종한\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\postgrest\_sync\request_ builder.py ", line 96, in execute raise APIError(dict(json_obj)) postgrest.exceptions.APIError: {'message': 'permission denied for table economic_and_stock_data', 'code': '42501', 'hint': 'Grant the required privileges to the current role with: GRANT SELECT ON public.economic_and_stock_data TO service_role;', 'details': None} ERROR: Traceback (most recent call last): File "C:\박영준\banbu-stocktrading-final\app\services\economic_ service.py ", line 134, in update_economic_data_in_background prev_data_response = supabase.table("economic_and_stock_data").select("*").eq("날짜", previous_date).execute() ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^ File "C:\Users\박종한\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\postgrest\_sync\request_ builder.py ", line 96, in execute raise APIError(dict(json_obj)) postgrest.exceptions.APIError: {'message': 'permission denied for table economic_and_stock_data', 'code': '42501', 'hint': 'Grant the required privileges to the current role with: GRANT SELECT ON public.economic_and_stock_data TO service_role;', 'details': None} During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Users\박종한\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\starlette\ routing.py ", line 638, in lifespan async with self.lifespan_context(app) as maybe_state: ~~~~~~~~~~~~~~~~~~~~~^^^^^ File "C:\Users\박종한\AppData\Local\Python\pythoncore-3.14-64\Lib\ contextlib.py ", line 214, in aenter return await anext(self.gen) ^^^^^^^^^^^^^^^^^^^^^ async with original_context(app) as maybe_original_state: async with original_context(app) as maybe_original_state: ~~~~~~~~~~~~~~~~^^^^^ async with original_context(app) as maybe_original_state: ~~~~~~~~~~~~~~~~^^^^^ File "C:\Users\박종한\AppData\Local\Python\pythoncore-3.14-64\Lib\ contextlib.py ", line 214, in aenter return await anext(self.gen) ^^^^^^^^^^^^^^^^^^^^^ File "C:\박영준\banbu-stocktrading-final\app\ main.py ", line 18, in lifespan await startup() File "C:\박영준\banbu-stocktrading-final\app\ main.py ", line 48, in startup await update_economic_data_in_background() File "C:\박영준\banbu-stocktrading-final\app\services\economic_ service.py ", line 251, in update_economic_data_in_background raise Exception(f"경제 데이터 업데이트 중 오류: {str(e)}") Exception: 경제 데이터 업데이트 중 오류: {'message': 'permission denied for table economic_and_stock_data', 'code': '42501', 'hint': 'Grant the required privileges to the current role with: GRANT SELECT ON public.economic_and_stock_data TO service_role;', 'details': None}
요약 프롬프트의 영문 버전 을 만들 때, 출력 규칙에 포함된 한글 부분은 영어로 번역하지 않고 그대로 유지 하고 싶음 영문 편과 한글 편을 한 번에 함께 출력받고 싶음 그러면 전체 비용도 저렴해지고 쇼츠 생산 속도도 빨라질 것 같아서 이런 방법은 어떨지 생각해보고 가능한지 질문 드리게되었습니다.
1. 현재 학습 진도 섹션 3 15강 수강 2. 어려움을 겪는 부분 아직 섹션3 15강밖에 수강하지 않았지만 예전에 배포했을때 설정 문제로 과금이 나간적이있어서 강의는 계속 들으면서 로컬에서 해보고 개인 프로젝트에 적용해보는것이 좋을까요? 아니면 둘 다 하는것이 좋을까요??