728x90
반응형

IT 156

플라스크 sqlalchemy 조인 에러 : Could not determine join condition between parent/child tables on relationship TenantRoles.tenant - there are no foreign keys linking these tables

model을 아래와 같이 Many to One으로 정의하고 class Tenants(db.Model): tenant_id = db.Column(db.Integer, primary_key=True, nullable=False) ... class TenantRoles(db.Model): ... tenant_id = db.Column(db.Integer, db.ForeignKey('Tenants.tenant_id'), nullable=True) tenant = db.relationship('Tenants', backref=db.backref('tenant_role')) db상에서도 fk로 연결이 되어있는데 실행해보면 에러남 이 에러메시지의 최하단에 나오는 문구는 이것 sqlalchemy.exc.NoForeig..

IT/파이썬 2021.06.16

PostgreSQL 세션 신규 연결시 에러 (FATAL: sorry, too many clients already)

말 그대로 클라이언트 연결 수량이 초과되었다는 뜻 /etc/postgresql/main/posgresql.conf # /etc/postgresql로 이동 ubuntu@...:/etc/postgresql$ ll total 12 drwxr-xr-x 3 postgres postgres 4096 May 20 06:18 ./ drwxr-xr-x 106 root root 4096 Jun 4 08:52 ../ drwxr-xr-x 3 postgres postgres 4096 May 20 06:18 13/ # vi 편집기로 main/postgresql.conf 까지 접속 ubuntu@...:/etc/postgresql$ sudo vi 13/ 여기에서 max_connection 찾아서 수량 늘려줌 늘려준 후에는 오른쪽 주..

IT/서버 2021.06.14

파이참 프로젝트 루트 디렉토리 이름 변경 안되는 문제 (java.io.ioexception cannot rename)

여기에서 service-one을 resource-server로 이름을 바꾸고 싶었다. 우클릭 > refactor > rename으로 이름 변경을 시도하지만 안바꿔준다. 참고 : https://stackoverflow.com/questions/56107963/renaming-project-root-directory-in-pycharm-gives-java-io-ioexception 스택오버플로우를 뒤져보니 어디선가 해당 프로젝트를 사용중이어서 그렇단다. 그 글을 보고 문득.... 콘솔창을 보니 앱이 실행중이었다. ...정지하고 다시 rename하니 잘 된다^^!!!

IT/파이썬 2021.06.14

JUnit으로 테스트코드 실행했는데 no tests 에러 뜰때 (No tests found for given includes)

문제 @RunWith(SpringRunner.class) @SpringBootTest public class UserApiDocumentation { ... @Test public void testRead() throws Exception { this.mockMvc.perform(get("/api/user/{id}", 1)) .... } } 이렇게 테스트 코드를 짜고 실행했는데 테스트를 찾을 수 없다고 나온다.... 해결 (인텔리제이 커뮤니티버전 기준) 좌측상단 File 메뉴 > settngs > Build, Execution, Deployment > Gradle 여기에서 Run test using을 Gradle에서 IntelliJ IDEA로 변경 failed 떴지만 어쨌든 테스트는 돌아갔다! 참고 ht..

gunicorn 서비스로 등록하기

gunicorn의 시작, 중지를 쉽게 하고 리눅스 서버 재부팅시 gunicorn 자동실행을 위해 환경 변수 파일 생성 /home/ubuntu/venv/myproject.env FLASK_APP=pybo FLASK_ENV=development APP_CONFIG_FILE=/home/ubuntu/projects/myproject/config/production.py 서비스 파일 생성 /etc/systemd/system/myproject.service [Unit] Description=gunicorn daemon After=network.target [Service] User=ubuntu Group=ubuntu WorkingDirectory=/home/ubuntu/projects/myproject Enviro..

IT/서버 2021.06.07

wsgi 서버

wsgi (Web Server Gateway Interface, 위스키) 웹서버와 웹 애플리케이션의 인터페이스를 위한 파이썬 프레임워크 ex) nginx와 flask 앱 사이에서 동작 wsgi 서버 종류 : uwsgi, gunicorn 등 설치는 pip로 pip install gunicorn 실행 위치 : flask 프로젝트가 있는 폴더에서 명령 포트로 서버 띄우려면 gunicorn --bind 0:5000 "pybo:create_app()" 유닉스 소켓 사용해서 실행 gunicorn --bind unix:/tmp/myproject.sock "pybo:create_app()" 소켓 방식으로 실행하면 브라우저에 url 쳐서 접속 불가 웹서버(nginx 등)가 유닉스 소켓으로 wsgi 서버에 접속해야 함

IT/서버 2021.06.07
300x250
반응형