Remove __pycache__ from repo
This commit is contained in:
BIN
backend/app/__pycache__/db_engine.cpython-313.pyc
Normal file
BIN
backend/app/__pycache__/db_engine.cpython-313.pyc
Normal file
Binary file not shown.
BIN
backend/app/__pycache__/init_db.cpython-313.pyc
Normal file
BIN
backend/app/__pycache__/init_db.cpython-313.pyc
Normal file
Binary file not shown.
@@ -5,11 +5,11 @@ import os
|
||||
|
||||
dotenv.load_dotenv()
|
||||
|
||||
PG_USER = dotenv.get_key(".env", "PG_USER")
|
||||
PG_PASSWORD = dotenv.get_key(".env", "PG_PASSWORD")
|
||||
PG_HOST = dotenv.get_key(".env", "PG_HOST")
|
||||
PG_PORT = dotenv.get_key(".env", "PG_PORT")
|
||||
PG_DB = dotenv.get_key(".env", "PG_DB")
|
||||
PG_USER = dotenv.get_key(".env", "POSTGRES_USER")
|
||||
PG_PASSWORD = dotenv.get_key(".env", "POSTGRES_PASSWORD")
|
||||
PG_HOST = dotenv.get_key(".env", "POSTGRES_HOST")
|
||||
PG_PORT = dotenv.get_key(".env", "POSTGRES_PORT")
|
||||
PG_DB = dotenv.get_key(".env", "POSTGRES_DB")
|
||||
|
||||
DATABASE_URL = (
|
||||
f"postgresql+asyncpg://{PG_USER}:{PG_PASSWORD}@{PG_HOST}:{PG_PORT}/{PG_DB}"
|
||||
@@ -17,7 +17,7 @@ DATABASE_URL = (
|
||||
|
||||
engine = create_async_engine(
|
||||
DATABASE_URL,
|
||||
echo=False,
|
||||
echo=False,
|
||||
future=True,
|
||||
)
|
||||
|
||||
@@ -31,6 +31,7 @@ async_session_maker = async_sessionmaker(
|
||||
class Base(DeclarativeBase):
|
||||
pass
|
||||
|
||||
|
||||
async def get_async_session():
|
||||
async with async_session_maker() as session:
|
||||
yield session
|
||||
@@ -39,4 +40,3 @@ async def get_async_session():
|
||||
async def init_db():
|
||||
async with engine.begin() as conn:
|
||||
await conn.run_sync(Base.metadata.create_all)
|
||||
|
||||
|
||||
9
backend/app/init_db.py
Normal file
9
backend/app/init_db.py
Normal file
@@ -0,0 +1,9 @@
|
||||
from app.db_engine import init_db
|
||||
|
||||
from app.models.posts import Post
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import asyncio
|
||||
|
||||
asyncio.run(init_db())
|
||||
0
backend/app/models/__init__.py
Normal file
0
backend/app/models/__init__.py
Normal file
BIN
backend/app/models/__pycache__/__init__.cpython-313.pyc
Normal file
BIN
backend/app/models/__pycache__/__init__.cpython-313.pyc
Normal file
Binary file not shown.
BIN
backend/app/models/__pycache__/posts.cpython-313.pyc
Normal file
BIN
backend/app/models/__pycache__/posts.cpython-313.pyc
Normal file
Binary file not shown.
0
backend/app/schemas/__init__.py
Normal file
0
backend/app/schemas/__init__.py
Normal file
0
backend/app/schemas/guestbook.py
Normal file
0
backend/app/schemas/guestbook.py
Normal file
30
backend/app/schemas/posts.py
Normal file
30
backend/app/schemas/posts.py
Normal file
@@ -0,0 +1,30 @@
|
||||
from pydantic import BaseModel, Field
|
||||
from typing import Optional
|
||||
|
||||
|
||||
class PostCreate(BaseModel):
|
||||
title: str = Field(min_length=3, max_length=150)
|
||||
content: str = Field(min_length=10)
|
||||
images: Optional[str] = Field()
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
||||
|
||||
|
||||
class PostRead(BaseModel):
|
||||
id: int = Field()
|
||||
title: str = Field(min_length=3, max_length=150)
|
||||
content: str = Field(min_length=10)
|
||||
images: str = Field()
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
||||
|
||||
|
||||
class PostUpdate(BaseModel):
|
||||
title: str = Field(min_length=3, max_length=150)
|
||||
content: str = Field(min_length=10)
|
||||
images: Optional[str] = Field()
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
||||
@@ -1,8 +1,9 @@
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:18-alpine3.22
|
||||
restart: always
|
||||
ports:
|
||||
- "5432:5432"
|
||||
- "5432:5432"
|
||||
environment:
|
||||
POSTGRES_USER: ${POSTGRES_USER}
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
||||
|
||||
Reference in New Issue
Block a user