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()
|
dotenv.load_dotenv()
|
||||||
|
|
||||||
PG_USER = dotenv.get_key(".env", "PG_USER")
|
PG_USER = dotenv.get_key(".env", "POSTGRES_USER")
|
||||||
PG_PASSWORD = dotenv.get_key(".env", "PG_PASSWORD")
|
PG_PASSWORD = dotenv.get_key(".env", "POSTGRES_PASSWORD")
|
||||||
PG_HOST = dotenv.get_key(".env", "PG_HOST")
|
PG_HOST = dotenv.get_key(".env", "POSTGRES_HOST")
|
||||||
PG_PORT = dotenv.get_key(".env", "PG_PORT")
|
PG_PORT = dotenv.get_key(".env", "POSTGRES_PORT")
|
||||||
PG_DB = dotenv.get_key(".env", "PG_DB")
|
PG_DB = dotenv.get_key(".env", "POSTGRES_DB")
|
||||||
|
|
||||||
DATABASE_URL = (
|
DATABASE_URL = (
|
||||||
f"postgresql+asyncpg://{PG_USER}:{PG_PASSWORD}@{PG_HOST}:{PG_PORT}/{PG_DB}"
|
f"postgresql+asyncpg://{PG_USER}:{PG_PASSWORD}@{PG_HOST}:{PG_PORT}/{PG_DB}"
|
||||||
@@ -31,6 +31,7 @@ async_session_maker = async_sessionmaker(
|
|||||||
class Base(DeclarativeBase):
|
class Base(DeclarativeBase):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
async def get_async_session():
|
async def get_async_session():
|
||||||
async with async_session_maker() as session:
|
async with async_session_maker() as session:
|
||||||
yield session
|
yield session
|
||||||
@@ -39,4 +40,3 @@ async def get_async_session():
|
|||||||
async def init_db():
|
async def init_db():
|
||||||
async with engine.begin() as conn:
|
async with engine.begin() as conn:
|
||||||
await conn.run_sync(Base.metadata.create_all)
|
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,6 +1,7 @@
|
|||||||
services:
|
services:
|
||||||
postgres:
|
postgres:
|
||||||
image: postgres:18-alpine3.22
|
image: postgres:18-alpine3.22
|
||||||
|
restart: always
|
||||||
ports:
|
ports:
|
||||||
- "5432:5432"
|
- "5432:5432"
|
||||||
environment:
|
environment:
|
||||||
|
|||||||
Reference in New Issue
Block a user