Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
24 lines (19 loc) · 620 Bytes

File metadata and controls

24 lines (19 loc) · 620 Bytes
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker, declarative_base
# SQLite 데이터베이스 URL
SQLALCHEMY_DATABASE_URL = "sqlite:///./test.db"
# 데이터베이스 엔진 생성
engine = create_engine(
SQLALCHEMY_DATABASE_URL, connect_args={"check_same_thread": False} # SQLite는 멀티스레드 사용 시 설정 필요
)
# 세션 로컬 클래스 생성
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
# 기본 클래스 선언
Base = declarative_base()
# 의존성 주입
def get_db():
db = SessionLocal()
try:
yield db
finally:
db.close()
Morty Proxy This is a proxified and sanitized view of the page, visit original site.