Initial commit with authentication and routes for registering/login already set up

This commit is contained in:
2024-10-14 05:38:48 +00:00
commit f64068c8ff
23 changed files with 1253 additions and 0 deletions

25
app/database.py Normal file
View File

@ -0,0 +1,25 @@
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession
import os
# Set up the database URL (adjust to your psycopg3 format)
DATABASE_URL = os.getenv("DATABASE_URL", "postgresql+psycopg://postgres:postgresbro@10.0.0.124/scrap")
# Create the async engine with psycopg3
engine = create_async_engine(DATABASE_URL, echo=True)
# Create the sessionmaker for async sessions
SessionLocal = sessionmaker(
bind=engine,
class_=AsyncSession,
autocommit=False,
autoflush=False,
)
Base = declarative_base()
# Dependency for getting the database session
async def get_db():
async with SessionLocal() as session:
yield session