프로그래밍/DB
-
psycopg2.OperationalError: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"?프로그래밍/DB 2020. 3. 27. 19:51
postgresql 오류 처리 어느날 서버가 갑자기 다운되어서 재시작을 한 후 매번 잘 돌아가던 python 스크립트에서 갑자기 오류를 내기 시작했다. 참고로 스크립트에서 변경된 사항은 전혀 없었다. Traceback (most recent call last): File "getInfoPost.py", line 379, in conn = pc.connect("dbname=realdbname user=username password=realpass") File "/root/anaconda3/lib/python3.6/site-packages/psycopg2/__init__.py", line 130, in connect conn = _connect(dsn, connection_factory=connection..
-
sed로 " 안의 , 제거하기프로그래밍/DB 2020. 1. 8. 15:07
load data infile로 csv 파일 내용을 mysql 테이블로 import했는데 warning 개수가 넘 많다 -_-;; LOAD DATA INFILE '/var/lib/mysql-files/sample.csv' INTO TABLE sampleFIELDS TERMINATED BY ','IGNORE 1 LINES; Query OK, 12147957 rows affected, 65535 warnings (1 min 44.92 sec) show warnings; 로 경고 메세지를 확인하니 아래와 같이 테이블의 input columns 개수보다 칼럼 개수가 많다고 한다. Warning | 1265 | Data truncated for column '전용면적' at row 3758 || Warning |..
-
postgreSQL 사용법 - 테이블 업데이트프로그래밍/DB 2019. 9. 28. 16:09
postgresql 테이블 업데이트 방법 ( how to update postgresql table ) 다른 테이블 필드 값으로 업데이트 update table2 as f set field1 = h.field1 from table1 as h where f.field2 = 2 and f.id = h.id; 같은 테이블 필드를 분리해서 업데이트 update 테이블이름 set 본번 = split_part(지번, '-',1); 특정 값으로 전체 필드 업데이트 update 테이블이름 set 칼럼이름='문자열'