์ ์ฒด ๊ธ15 [DATABASE] ์คํฐ๋ ํ๊ณ /ํ๊ธฐ/ํผ๋๋ฐฑ 1. ์คํฐ๋ ์งํ ๋ฐฉ์ - ์ฃผ 1ํ, ์ด 4๋ช ์ด ํ ํ์ผ๋ก ์งํ - ์ด๋ฐ 20๋ถ์ ๋ฉํ ๋์ ํ์ตํ, ๋ฉด์ ํ, ์ฃผ์ฐจ๋ณ ์ง์์๋ต ์๊ฐ์ ๊ฐ๋๋ค. - ์ดํ์๋ 1๋ช ๋ฉด์ ์, 2๋ช ๋ฉด์ ๊ด, 1๋ช ๊ธฐ๋ก์ ์ ์ญํ ๋ก ์งํํ๊ณ ๊ฐ ํ์ ์คํฐ๋๊ฐ ์ข ๋ฃ๋๋ฉด ์์ ๋กญ๊ฒ ํด์ฅํ๋ค. - ๋ฉด์ ์ ๋น 20๋ถ์ฉ ๊ธฐ์ ๋ฉด์ ์ ์งํํ๊ณ ํผ๋๋ฐฑ 5๋ถ ํ๋ ๋ฐฉ์์ด๋ค. - ๋ฉํ ๋๊ป์ ๊ฐ ํ์ ๋์๋ค๋๋ฉด์ ๋ฉด์ ํผ๋๋ฐฑ์ ์งํํด์ฃผ์๊ณ , ๋ชจ์๋ฉด์ ์งํ ์ค ๋์จ ์ง๋ฌธ์ด ์๋ค๋ฉด ๋ฉํ ๋๊ณผ ์ง์์๋ต์ด ์ด๋ฃจ์ด์ง๋ค. 2. ์ค๊ฐฑ์ด์ ํ์ต ๊ณผ์ /๋ฐฉ๋ฒ step1. ๋ ธ์ ํ์ด์ง์ ๊ณต์ ํด์ฃผ์ ์ง๋ฌธ์ ํค์๋ ์์ฃผ๋ก ํ์ต (๊ฐ ์ง๋ฌธ๋ค์ด ์ฐ๊ฒฐ๋์ด ์์) step2. ๊ณต๋ถํ๋ค๋ณด๋ฉด ์ดํด ์๋๋ ๋ถ๋ถ๋ ์๊ณ , ์ถ๊ฐ์ ์ธ ํ์ต์ด ํ์ํ ๋ถ๋ถ์ด ์๊ธด๋ค. step3. ๊ทธ ๋ถ๋ถ์ ๋ ธ์ ํ์ด.. 2023. 10. 16. [Python/ERROR] Circular import (Runtime๊ณผ Import Time์ ์ฐจ์ด์ ) ์๋ฌ๋ฉ์์ง ImportError: cannot import name 'db' from partially initialized module 'app' (most likely due to a circular import) ํด๋น ์๋ฌ๋ ๋ชจ๋ ๊ฐ์ ์๋ก๋ฅผ "์ํธ ์ฐธ์กฐ"ํ ๋ ๋ฐ์ํ๋ค. ์๋ก์ด ๋ชจ๋์ import ํด์ค ๋ ๊ผฌ์ด๋ฉด ํด๋น ์๋ฌ๊ฐ ๋ฐ์ํ๋ค. ๋์ ๊ฒฝ์ฐ Flask ํ๋ ์์ํฌ๋ฅผ ์ด์ฉํด์ ์๋์ ๊ฐ์ ํด๋ ๊ตฌ์กฐ๋ก ๊ฐ๋ฐํ๋ค๊ฐ ์์ ์๋ฌ๋ฅผ ๋ง๋๊ฒ ๋์๋ค. (์๋ ํด๋๊ตฌ์กฐ๋ ๋จ์ํํ ๊ฒ์) app/ โโโ __init__.py โโโ models.py โโโ routers.py โโโ config.py โโโ run.py app.py 1. __init__.py์ models.py์ app.py ํ์ผ์ ๊ฐ๊ฐ ์์ธํ.. 2023. 4. 24. [PostgreSQL ERROR] psycopg2.errors.UniqueViolation: duplicate key value violates unique constraint "0000_key"DETAIL: Key (0000)=() already exists. my github issue link: https://github.com/Gaebal-Zarang/gbzr-backend/issues/4 ์๋ฌ๋ฉ์์ง psycopg2.errors.UniqueViolation: duplicate key value violates unique constraint "users_user_nickname_key" DETAIL: Key (nickname)=() already exists. - ์ฐธ๊ณ ํ ๋ฐฉ๋ฒ : https://snepbnt.tistory.com/252 : https://www.xmisao.com/2014/06/07/duplicate-key-value-violates-unique-constant-primary-key-on-postgresql.html - ํด๊ฒฐ ๋ฐฉ๋ฒ 1. D.. 2023. 4. 19. [Deploy] AWS EC2 ์ธ์คํด์ค ์์ฑ ๋ฐ Django ํ๋ก์ ํธ ๋ฐฐํฌํ๊ธฐ What is this? - AWS EC2: ์ธ์คํด์ค, ๊ฐ์์ ์ปดํจํฐ ์ด๋ค. EC2 ๋? Elastic Compute Cloud์ ์ค์๋ง = ์ปดํจํฐ๋ฅผ ํต์งธ๋ก ๋น๋ ค์ฃผ๋ ์ปดํจํฐ ์๋ ์๋น์ค = ์๊ฒฉ ์ ์ด๋ฅผ ์ด์ฉํด์ ์ปดํจํฐ๋ฅผ ์กฐ์ํ๊ณ ๋ ์ด์ ํ์๊ฐ ์์ด์ง ๊ฒฝ์ฐ, ์ธ์ ๋ ์ง ๋ฒ๋ฆด ์ ์๋ ์๋น์ค ec2์์๋ ๋์ฌํ๋ ํ ๋์ ๊ฐ์์ปดํจํฐ๋ฅผ '์ธ์คํด์ค' ๋ผ๊ณ ๋ถ๋ฅธ๋ค. 1๏ธโฃ ์ธ์คํด์ค ์์ฑํ๊ธฐ 0. ์ปดํจํฐ๋ฅผ ๋น๋ฆฌ๊ธฐ ์ ๋จผ์ ํด์ผํ ๊ฒ์ ์ด๋ค ๋ฆฌ์ (์ง์ญ)์ ์๋ ์ปดํจํฐ๋ฅผ ๋น๋ฆด ๊ฒ์ธ์ง ์ ํ๋ ๊ฒ ์ง์ญ์ 'ํ๊ตญ>์์ธ'๋ก ์ค์ ํด์ค๋ค. 1. โ์ธ์คํด์ค ์์โ ๋ฒํผ : ์๋ก์ด ์ปดํจํฐ๋ฅผ ๋น๋ฆด ๋ ๊ทธ ์ปดํจํฐ์ ๊ธฐ๋ณธ์ ์ผ๋ก ์ด๋ค ์ด์์ฒด์ , ์ด๋ค ์๋น์ค๊ฐ ์ค์น๋ ์ง ์ง์ ํ ์ ์๋ค. 2. ์ฌ์ฉํ OS๋ฅผ ์ ํํ๋ค. ๋๋ ubuntu๋ก ์ ํ.. 2023. 3. 7. [TIL] MySQL ๋ช ๋ น์ด ์ ๋ฆฌ 1. ๋ฐ์ดํฐ๋ฒ ์ด์ค ์ ์ : MYSQL ํด๋ผ์ด์ธํธ๋ก ์ ์ํ๊ธฐ ์ํด์ ํฐ๋ฏธ๋์ ์๋์ ๊ฐ์ ๋ช ๋ น์ด๋ฅผ ์ ๋ ฅ $ mysql -u ์ฌ์ฉ์์ด๋ฆ -p 2. ๋ฐ์ดํฐ๋ฒ ์ด์ค ์กฐํ : MYSQL ์๋ฒ์ ์๋ ๋ฐ์ดํฐ๋ฒ ์ด์ค ์กฐํ mysql> SHOW DATABASES; 3. ๋ฐ์ดํฐ๋ฒ ์ด์ค ์ ํ : MYSQL ์๋ฒ์ ์ ์ ํ, ์ฌ์ฉํ ๋ฐ์ดํฐ๋ฒ ์ด์ค ์ ํ mysql> USE ๋ฐ์ดํฐ๋ฒ ์ด์ค์ด๋ฆ; 4. ํ ์ด๋ธ ์กฐํ : ์ ํํ ๋ฐ์ดํฐ๋ฒ ์ด์ค์ ์๋ ํ ์ด๋ธ์ ์กฐํ mysql> SHOW TABLES; 5. ๋ฐ์ดํฐ๋ฒ ์ด์ค ๋ง๋๋ ๋ช ๋ น์ด mysql> CREATE DATABASE ๋ฐ์ดํฐ๋ฒ ์ด์ค์ด๋ฆ; 6. ๋ฐ์ดํฐ๋ฒ ์ด์ค ์ญ์ ํ๋ ๋ช ๋ น์ด ๋ฐ์ดํฐ๋ฒ ์ด์ค ๊ฐ์ฒด(์คํค๋ง)๋ฅผ ์ญ์ ํ๋ ๋ช ๋ น์ด ํด๋น ๋ฐ์ดํฐ๋ฒ ์ด์ค์ ๋ฐ์ดํฐ๋ฒ ์ด์ค ๋ด๋ถ์ ๋ชจ๋ ๊ฐ์ฒด(ํ ์ด๋ธ, ๋ทฐ, ์ธ๋ฑ์ค ๋ฑ)๊ฐ .. 2023. 3. 6. [TIL] FastAPI tutorial (based documentation) ์ฐธ๊ณ ํ ๊ณต์ ๋ฌธ์(tutorial): https://fastapi.tiangolo.com/tutorial ์ฐธ๊ณ ํ ๊ณต์ ๋ฌธ์(advanced): https://fastapi.tiangolo.com/advanced ์ฐธ๊ณ ํ fastapi BLOG: https://lucky516.tistory.com/97 ์ค๊ฐฑ์ ๊นํ๋ธ ๋งํฌ: https://github.com/mathtkang/fastapi-tutorial ์์ฑํ ๋ ธ์ ํ์ด์ง: https://sprinkle-piccolo-9fc.notion.site/TIL-FastAPI-tutorial-13052523e8ae48ad8b3e1c66ce859aa9 TIL (FastAPI tutorial) from fastapi import FastAPI app = FastAPI().. 2023. 3. 6. [TIL] Django tutorial (based documentation) ์ฐธ๊ณ ํ ๊ณต์ ๋ฌธ์: https://docs.djangoproject.com/ko/4.1 ์ค๊ฐฑ์ ๊นํ๋ธ ๋งํฌ: https://github.com/mathtkang/django-tutorial ์์ฑํ ๋ ธ์ ํ์ด์ง: https://sprinkle-piccolo-9fc.notion.site/TIL-Django-tutorial-eb8fec3e3f2a4592b880dbda311f9749 TIL (Django tutorial) docs tutorial์ ๋ณด๋ฉด์, ๋ด๊ฐ ์๋กญ๊ฒ ์๊ฒ๋ ๊ฒ ์์ฃผ๋ก ์ ๋ฆฌํฉ๋๋ค. + ์ํ๋๋๋ก ์ปค์คํ ํด๋ณด๊ธฐ! https://docs.djangoproject.com/ko/4.1 sprinkle-piccolo-9fc.notion.site 2023. 3. 6. [TIL] pyenv + poetry๋ก ๊ฐ๋ฐํ๊ฒฝ์ธํ ํ๊ธฐ (+ python interpreter setting) (๊ฐ์ํ๊ฒฝ์ ์ฌ์ฉํ๋ ์ด์ ์ ๋ํด์๋ ์ค๋ช ํ์ง ์์) ๋ ์ธ๋ถ์ ์ธ, ๊ฐ๊ฐ์ ์๋ํํฐ๋ค์ ์ฌ์ฉ ๋ชฉ์ ์ด์ ์ ๋ํด ์ค๋ช pyenv & pip & poetry ์ ์ฐจ์ด์ - venv : python ๊ฐ์ํ๊ฒฝ์ ๋ง๋ค์ด์ค - pyenv: ์ฌ๋ฌ ๋ฒ์ ์ python์ ์ค์นํ๊ณ ์ํ๋ python version์ ์ ํํ ์ ์๋๋ก ๋์์ค ์ฌ์ฉ์๋ณ๋ก ๊ธ๋ก๋ฒ ํ์ด์ฌ ๋ฒ์ ์ ์ค์ ํ ์ ์์ด์. (Let you change the global Python version on a per-user basis.) ํ๋ก์ ํธ๋ณ๋ก ํ์ด์ฌ ๋ฒ์ ์ ์ค์ ํ ์ ์์ด์. (Provide support for per-project Python versions.) ํ๊ฒฝ๋ณ์๋ก ํ์ด์ฌ ๋ฒ์ ์ ๋์ฒดํ ์ ์์ด์. (Allow you to overrid.. 2022. 3. 20. [TIL] Postgres/PostgreSQL ๋ช ๋ น์ด ์ ๋ฆฌ [psql DB ์ ์] $ psql -h localhost -U -d [psql shell ์ง์ ] $ psql ๊ธฐ๋ณธ์ ์ผ๋ก psql์์๋ postgres ๋ผ๋ ์ ์ ๊ฐ ์์ฑ๋์ด ์๋ค. ๊ทธ๋์ $ psql -U postgres -h localhost ๋ฅผ ์ ๋ ฅํ๊ณ psql ์ค์น์ ์ ๋ ฅํ ๋น๋ฐ๋ฒํธ๋ฅผ ์ ๋ ฅํ๋ฉด ์๋์ ๊ฐ์ด postgres(๋ db๊ฐ ์๋์ง๋ง)๋ช ์ psql ์์ด ์ด๋ฆฌ๋ ๊ฒ์ ๋ณผ ์ ์๋ค. (์๋๋ psql ์์ด ์ด๋ฆด ๋ ๋์ค๋ =# ์๋ถ๋ถ์ DB name์ด๋ค.) 1๏ธโฃ USER - postgres ๊ณ์ (USER) ๋ชฉ๋ก ์กฐํ ๋ฐฉ๋ฒ =# SELECT * FROM PG_USER; =# \du 2022. 3. 17. [ERROR] ERROR: syntax error at or near "-" # ์๋ฌ ๋ฐ์ ์ํฉ 'practice'๋ผ๋ DB์์ 'fastapi-pracitce'๋ผ๋ DB๋ฅผ ์ญ์ ํ๊ณ ์ถ์ (DROP DATABASE) '-' ๊ตฌ๋ฌธ ์๋ฌ๊ฐ ๋ฐ์ํ๊ฒ ๋จ # ์๋ฌ ํด๊ฒฐ ๋ฐฉ๋ฒ =# DROP DATABASE fastapi-practice; ๋ผ๊ณ ํ๋ฉด DBname์ '-' ๊ฐ ์์ด์ ํ๋์ DBname์ผ๋ก ์ธ์์ ๋ชปํ๊ณ ์๋ฌ๊ฐ ๋ฐ์ํ๋๊ฑฐ์๋ค! THEREFORE, DBname์ ํ๋๋ก ์ธ์ํ๋๋ก, ""(stringํ)์ผ๋ก ๊ฐ์ธ์ค 2022. 3. 1. DROP DATABASE ํ ๋, ์ด์ ๋ฐ์ ๋ฐ ํด๊ฒฐ๋ฐฉ๋ฒ my github issue link: https://github.com/Gaebal-Zarang/gbzr-backend/issues/5 ์๋ฌ๋ฉ์์ง ERROR: database "gbzrdb" is being accessed by other users DETAIL: There is 1 other session using the database. - ์ฐธ๊ณ ๋ฐ ํด๊ฒฐ ๋ฐฉ๋ฒ: https://scriptcrunch.com/there-is-1-other-session 2022. 1. 29. [Git] git commit message template ์ ์ฉํ๊ธฐ ์ด์ ํฌ์คํ (https://kkangsg.tistory.com/95)์์ commit message convention์ ๋ํด ์์๋ณด์๋ค. ์ด๋ฒ ํฌ์คํ ์์๋ ํด๋น convention์ ๋ฐ๋ฅด๋ Git commit message template ์ ์ฒด๋ฅผ ์ดํด๋ณด๊ณ global๊ณผ local์ ์ ์ฉํด์ ์์ผ๋ก ๋์ ํ๋ก์ ํธ์ commit message template์ ์ ์ฉํ๋๋ก ํ๊ฒ ๋ค.๐ง 1. commit message template ์๊ฐ ๋๋ ์๋์ ๊ฐ์ ์ปค๋ฐ ๋ฉ์์ง ํ ํ๋ฆฟ์ ์ฌ์ฉํ๊ณ ์๋ค. Gitmoji๋ฅผ ์ฌ์ฉํ๊ณ ์ฐธ๊ณ ํด์ผํ ๋ถ๋ถ๋ค์ ์ถ๊ฐ๋ก ์ ์ด์ฃผ์๋ค. (ํ ํ๋ฆฟ์ ๋ด์ฉ์ด ์ ์ด๋ ๊ฒ ๊ตฌ์ฑ๋์๋์ง ์๊ณ ์ถ๋ค๋ฉด ์ด์ ํฌ์คํ (convention)์ ๋ํด ์ฐธ๊ณ ํ๋ฉด ๋๋ค) ################ # : ์ ํ์.. 2021. 9. 12. [Git] git commit message convention์ ๋ํด ์์๋ณด๊ธฐ ์ง๊ธ๊น์ง ๊น์ ์ด์ฉํ ๋ฒ์ ๊ด๋ฆฌ๋ฅผ ํ๋ฉด์ ์๋ง์ ์ปค๋ฐ์ ํ์ง๋ง, ์ ์ฅ๋ง ์ํ๋ฉด ๋์ง ๋ญ~ ๋ผ๋ ์๊ฐ์ผ๋ก ์ปค๋ฐ ๋ฉ์์ง ์์ฑ์๋ ํฌ๊ฒ ์ ๊ฒฝ์ฐ์ง ์์๋ค. ๋์ถฉ ์ ์ฒด์ ์ผ๋ก ํฌ๊ด์ ์ธ ๋ฉ์์ง๋ฅผ ์ ๊ฑฐ๋ ๋ณ๊ฒฝ๋ ๋ถ๋ถ๋ค ์ค ๋ํ์ ์ผ๋ก ๋ฐ๋ ๋ถ๋ถ๋ง ์ ๊ธฐ๋ ํ์๋ค. ํ์ง๋ง ์ด๋ฒ ํ ํ๋ก์ ํธ๋ฅผ ์งํํ๋ฉด์ ๋ค๊ฐ์ด ํ๋์ ํ๋ก์ ํธ๋ฅผ ๋ถํ ํ์ฌ ์งํํ๊ณ pushํ๊ฒ ๋๋๊น, ์๋ก๊ฐ ์ด๋ค ๋ถ๋ถ์ ์ด๋ค ๋ชฉ์ ์ ๊ฐ์ง๊ณ ์ด๋ป๊ฒ ๊ตฌํํ๋์ง ์์์ผ ํ๋ ์ํฉ์ด ๋์๋ค. ๋ฌผ๋ก ๋ฐ์ผ๋ฆฌ ์คํฌ๋ผ์ ํตํด์ ํ์ฌ ์งํ ์ค์ธ ์์ ์ ๊ฐ๋จํ๊ฒ ๊ณต์ ํ๊ณ ์์ง๋ง, ๋ ๊ตฌ์ฒด์ ์ผ๋ก github repo์์ ์ง์ ์ฝ๋๋ฅผ ๋ณด๊ณ ์ด๋ ๋ถ๋ถ์ ์งํํ๋์ง ์ ์ ์๋ ๋ฐฉ๋ฒ์ผ๋ก git commit message template์ ์ฌ์ฉํ๊ธฐ๋ก ํ๋ค. ์ด๋ฒ ๊ธฐํ์ ๊ถ๊ธํ๋ ๋ถ๋ถ๋ค,.. 2021. 8. 17. [Git ๋ช ๋ น์ด ์ ๋ฆฌ] Repository์ add, commit, push, pull ํ๊ธฐ [Git] Repository์ main branch๋ก add, commit, push, pull ํ๊ธฐ //๋ก์ปฌ ๊น ์ ์ฅ์ ์์ฑ(.git ํด๋ ์์ฑ) $ git init //Working directory -> Staging Area $ git add [directory] $ git add . //Staging Area -> repository(.git) $ git commit -m "commit message" //add + commit ํ๋ฒ์ $ git commit -am "commit message" //์๊ฒฉ์ ์ฅ์์ ์ฐ๊ฒฐ $ git remote add origin [์๊ฒฉ์ ์ฅ์ ์ฃผ์] //ํ์ฌ ์ฐ๊ฒฐ๋ ์๊ฒฉ์ ์ฅ์ ํ์ธํ๊ธฐ $ git remote -v //์ฐ๊ฒฐ๋ ์๊ฒฉ์ ์ฅ์ ์ญ์ ํ๊ธฐ $ git remote.. 2021. 7. 30. [GitHub] Repository์ 'main' branch๋ก push ํ๊ธฐ ํด๋ ๋ฐ ํ์ผ๋ก ์ฝ๋์์ฑ์ ๋ค ํ ๋ค, ์๊ฒฉ์ ์ฅ์์ ์ ์ฅํ๋ ค๊ณ ํ๋ค. ๊นํ๋ธ ๋ ํฌ์งํ ๋ฆฌ์์ ์ด๋ก์ New ๋ฒํผ์ ๋๋ฌ์ commit-test ๋ผ๋ ๋ ํฌ์งํ ๋ฆฌ๋ฅผ ๋ง๋ค์ด๋ณด๊ฒ ๋ค. 3๊ฐ์ ์ฒดํฌ ๋ฐ์ค ์ค ์ฒซ ๋ฒ์งธ ๋ฐ์ค๋ฅผ ์ ํํ๊ณ Create ํ๋ฉด ์ด ๋ ํฌ์งํ ๋ฆฌ์์ main ์ด ๋ํดํธ ๋ธ๋์น๋ก ์ค์ ๋ ๊ฒ์ด๊ณ ๋์ค์ ์ค์ ์ ๋ค์ด๊ฐ์ ๋ฐ๊ฟ ์ ์๋ค๊ณ ๋์จ๋ค. ๋ ํฌ์งํ ๋ฆฌ๋ฅผ ์์ฑํ๋ฉด ์ด๋ ๊ฒ ๋์ค๋ ๊ฒ์ ๋ณผ ์ ์๋ค. README.md ํ์ผ์ ๋ง๋ค๊ณ ์ถ์ง ์๋ค๋ฉด ์ฒดํฌ๋ฅผ ํ์ง ์๊ณ ์์ฑํ๋ฉด ๋๋ค. (๊ทธ๋ฌ๋ฉด ๋์ค์ ์ปค๋ฐ ํธ์ฌ ํ ํ ๋ค์๊ณผ ๊ฐ์ ์๋ฆผ์ด ๋์จ๋ค) ์ผ๋จ ๋๋ README.md ํ์ผ์ ์์ฑํ ๋ฐฉํฅ์ผ๋ก ์๊ฒฉ์ ์ฅ์๋ฅผ ์ฌ์ฉํด๋ณด๊ฒ ๋ค. ๋ด๊ฐ ์ฌ์ฉํ๋ ์๋ํฐ๋ VSC(Visual Studio Code)์ด๋ค. test ํด๋๋ฅผ ๋ง.. 2021. 7. 10. ์ด์ 1 ๋ค์