본문 바로가기

Coding/Etc120

파이썬 TypeError: 'list' object is not callable 오류 해결 dept = []def dept():~ for d in dept:~ 위와 같은 코드로 작업을 하던 도중 TypeError: 'list' object is not callable 라는 에러가 발생했다. 알고보니 dept라는 리스트와 dept라는 함수가 둘 다 존재하기 때문이었다.가급적이면 변수와 함수는 같은 이름을 사용하지 말자. 2017. 11. 8.
-bash: cannot create temp file for here-document: No space left on device 오류해결 -bash: cannot create temp file for here-document: No space left on device 가끔 위와 같은 오류가 발생할 때가 있다.저장공간이 부족할 때 발생하는 오류이므로 어디에서 많은 용량을 잡아먹고 있는지 확인 후 조치해줘야 한다.df -h 후 해당 디렉토리로 이동한 다음df -hs ./* 2017. 10. 8.
add-apt-repository: command not found 오류해결 add-apt-repository: command not found add-apt-repository가 존재하지 않을 경우 위와 같은 에러가 발생한다.이런 경우 다음의 명령어를 통해 해결할 수 있다. sudo apt-get install software-properties-common python-software-properties 2017. 7. 12.
서로 다른 테이블 값 조인(Join) 시키기 [document테이블]- id- title- desc- author- etc [parts테이블]- id- item_per- item_req 위와 같은 두개의 테이블이 있다고 가정한다.document테이블의 id값은 정수이며 parts테이블은 정수|정수 형식으로 되어있다.나는 document테이블의 id값 중 |를 기준으로 split하여 뒤에 있는 정수 값을 얻고 해당 값을 통해document테이블의 id값과 비교를 하게 만들었다.목적은 다음과 같다.parts테이블을 조회하되, id에서 얻은 정수값을 통해 document테이블의 title, desc를 같이 표현해주고 싶다. SELECT a.id, b.title, b.desc, a.item_per, a.item_req FROM parts a LEFT JO.. 2017. 7. 8.
Auto increment 값 얻어오기 Get current auto_increment value현재의 auto increment 값을 얻어오려면 아래의 쿼리를 사용하면 된다. SELECT auto_increment FROM information_schema.tables WHERE table_schema='DBNAME' AND table_name='TABLE NAME' 2017. 7. 6.
MySQL CSV into outfile export 시 문제점 Include column name when using select into outfile. 최근 데이터베이스의 테이블을 csv파일로 export시키는 작업을 하던 중 문제를 발견했다.into outfile로 테이블을 덤프시키는데 이런 경우 컬럼명이 포함되지 않는다.나는 최상단에 컬럼명을 명시해주고 싶었으므로 해결방법을 찾아봤다.검색해보니 into outfile로 export하면 기본적으로 컬럼명이 포함되지 않는 것 같다.예를 들어 test라는 테이블에 no, id, pw라는 컬럼이 존재한다면 아래와 같은 쿼리문을 사용하면 된다. SELECT "no", "id", "pw" UNION SELECT * FROM test into outfile~ no, id, pw를 SELECT해주고 Union으로 기존 데이.. 2017. 7. 6.