Soumsa's picture
Goal:
c9dc9e5 verified
raw
history blame contribute delete
754 Bytes
```python
from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession
from sqlalchemy.orm import sessionmaker
from models.escalation_models import EscalationTicket, TicketResponse
import os
engine = create_async_engine(os.getenv("POSTGRES_URL"))
AsyncSessionLocal = sessionmaker(engine, class_=AsyncSession, expire_on_commit=False)
class PostgresService:
async def create_ticket(self, ticket: EscalationTicket) -> int:
async with AsyncSessionLocal() as session:
# Implementation for ticket creation
pass
async def get_tickets(self, status: str = None) -> list[TicketResponse]:
async with AsyncSessionLocal() as session:
# Implementation for ticket retrieval
pass
```