basement
This commit is contained in:
parent
836dd1d27a
commit
5f32db24bf
9 changed files with 300 additions and 14 deletions
29
main.py
29
main.py
|
|
@ -1,17 +1,23 @@
|
|||
from .config import app
|
||||
from .auth.router import router as auth_router
|
||||
|
||||
app.include_router(auth_router)
|
||||
|
||||
|
||||
'''
|
||||
from fastapi import FastAPI
|
||||
from pydantic import BaseModel, Field, EmailStr
|
||||
from sqlalchemy import (
|
||||
Column, Integer, String, DateTime, Enum, ForeignKey, Text, Float, Boolean, create_engine
|
||||
)
|
||||
from sqlalchemy.orm import declarative_base, relationship, sessionmaker
|
||||
from sqlalchemy.dialects.postgresql import JSONB
|
||||
from enum import Enum as PyEnum
|
||||
import datetime
|
||||
from sqlalchemy import Column, Integer, String, DateTime, Float, Text, Boolean, ForeignKey, Enum
|
||||
from sqlalchemy.orm import relationship
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
|
||||
app = FastAPI()
|
||||
Base = declarative_base()
|
||||
from .config import Base #databaese connection
|
||||
from .config import app #base app
|
||||
|
||||
# Enums
|
||||
|
||||
# Enums database
|
||||
class Role(str, PyEnum):
|
||||
admin = "admin"
|
||||
user = "user"
|
||||
|
|
@ -33,7 +39,6 @@ class VoteType(str, PyEnum):
|
|||
# SQLAlchemy Models
|
||||
class User(Base):
|
||||
__tablename__ = "users"
|
||||
|
||||
user_id = Column(Integer, primary_key=True, index=True)
|
||||
username = Column(String, unique=True, nullable=False)
|
||||
name = Column(String)
|
||||
|
|
@ -113,9 +118,5 @@ class VoteCreate(BaseModel):
|
|||
item_id: int
|
||||
vote_type: VoteType
|
||||
|
||||
# DB Setup (edit with your DB credentials)
|
||||
DATABASE_URL = "postgresql://username:password@localhost:5432/mydatabase"
|
||||
engine = create_engine(DATABASE_URL)
|
||||
SessionLocal = sessionmaker(bind=engine)
|
||||
Base.metadata.create_all(bind=engine)
|
||||
|
||||
'''
|
||||
Loading…
Add table
Add a link
Reference in a new issue