All Articles

TIL&TEL 20.02.17 ~ 20.02.23

TIL( Today I Learned)

  • 20-02-17 월

    • 팀 코드 살펴보기
    • 팀 미팅
  • 20-02-18 화

    • API 핸들링 에러없이 처리하기
    • 에러 디버깅
    • 프로세스 개선
  • 20-02-19 수

    • 업데이트된 내역 받기
    • 테이블 구조 수정
    • url 크롤링 퍼오는 내용 식별 리스트 만들어보기
    • 테스트 케이스 만들기
  • 20-02-20 목

    • 크롤러 프로세스 코드 짜기
    • 크롤링 탐구
  • 20-02-21 금

    • 크롤러 DB 연결
  • 20-02-22 토

    • 시간 값 DB 형식 처리 함수 만듬

TEL (Trial and Error Log)

  • 20-02-17

    • mysql 1205, ‘Lock wait timeout exceeded; try restarting transaction’
    • 커넥션에서 query excutr 만들어 놓고 commit을 안만들면 이런에러가 난다.
    • 작성하고 commit 하지 않은 테이블이 잠기면서 다른 transaction을 방해한다.
    • query value binidg error
    • python으로 바인딩을 넣을땐 ’ ’ 로 싸지 않아도 된다.
    • urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x10cbab510>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known
    • Firewall block because too many connection
    • Too many bad request!!
    • pymysql.err.OperationalError: (2003, “Can’t connect to MySQL server on ‘127.0.0.1’ ([Errno 24] Too many open files)“)
    • socket.gaierror: [Errno 8] nodename nor servname provided, or not known
    • porcess Error
  • 20-02-18

    • OSError: [Errno 24] Too many open files
    • process limit on mac system..
    • ulimit -n 1024 로 올림
    • 최대 프로세스는 cpu count로 계산해서 *2 하고 집어넣더라
    • BlockingIOError: [Errno 35] Resource temporarily unavailable
    • hit the limit of device process
    • with magic method *enter*, *exit*
    • 클래스 호출시 자동으로 trigger 되고, exit 하는 method를 선언 할 수있다.
    • JSONDecodeError(“Expecting value”, s, err.value) from None
    • 장고 model에서 json으로 설정 해놓았는데, mysql에서는 textfield로 되어있다. 그래서 decode에러 발생
    • ALTER TABLE collector MODIFY request_header JSON
  • 20-02-19

    • pytest 동작을 제대로 못함
    • test 안에 *init*.py 가 있을 경우 동작을 제대로 못하는 경우가 생긴다.
    • avoid “*init*.py” files in your test directories. This way your tests can run easily against an installed version of mypkg, independently from the installed package if it contains the tests or not.
    • python -m pytest 를 할 경우 동작함.
    • pycharm에서는 동작을 함
    • add source roots to PYTHONPATH 시 동작
    • 안할 시 error
    • django app 에서 makemigration을 못할 경우
    • Make sure that the migrations/ folder contains a \*init\*.pyfile
    • Lost half an hour over that.
  • 20-02-20

    • SyntaxError: unexpected EOF while parsing
    • except 구문 넣고 코드 비어 있으면 이렇게 됨.
    • pass 처리함
    • BS4 ResultSet object has no attribute ‘get’.
    • select로 고를시 DateSet 이 골라짐!!
    • select_one으로 변경
  • 20-02-21

    • create date django vs direct query
    • django 는 자동 생성 옵션을 걸어놓으면 장고에서 컨트롤, DB 에 해당 옵션이 걸리지 않음
    • direct query 는 value 입력해줘야 함
    • TypeError: unsupported operand type(s) for +: ‘int’ and ‘str’
    • js 에서는 str + int 가능
    • python 에서는 불가능
    • static method call
    • static이 다른 동일 class 의 static method를 호출 할때, 단순 호칭으로는 안된다. 앞에 클래스 명을 명시해야한다.
    • or 별도 함수인 것처럼 임포트를 해야 한다.
    • from 정의되 모듈 import method 이름 심지어 같은 파일 내에서도 !!
    • AttributeError: ‘str’ object has no attribute ‘startwith’
    • startswith( ) <= startwith( )
  • 20-02-22

    • 일정 형식의 자료를 처리할 때에는 일단 자료가 통일된 형태를 유지하는지부터 확인후, 작업에 들어가야 에러를 막는다.
    • SQL ,하나로 동작을 못함…
  • 20-02-23

    • from pudb import settrace; settrace( )
    • 로직이 돌아가면서 set_trace( ) 있는 곳이 걸리면 디버깅 작동 (break point )
    • 의미들을 파악하기 쉽고, 로직을 따라가고 조작도 간편하다.