Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Schemas, main database, main #84

Merged
merged 1 commit into from
Sep 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions game/utils/validation.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import parsec
import re

from game.config import ALLOWED_MODULES
Expand Down
7 changes: 7 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,11 @@ opencv-python~=4.8.0.76
Sphinx~=7.0.1
Myst-Parser~=2.0.0
furo~=2023.7.26
parsec~=3.15
opencv-python~=4.8.0.76
Sphinx~=7.0.1
Myst-Parser~=2.0.0
furo~=2023.7.26
SQLAlchemy~=2.0.2
pydantic~=2.3.0
fastapi~=0.103.1
Empty file added server/crud/__init__.py
Empty file.
10 changes: 10 additions & 0 deletions server/database.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker

DB_URL = 'sqlite:///./byte_server.db'

engine = create_engine(
DB_URL, connect_args={'check_same_thread': False}
)

SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
23 changes: 23 additions & 0 deletions server/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from fastapi import FastAPI, HTTPException, Depends
from sqlalchemy.orm import Session
from models.base import Base
from database import SessionLocal, engine

Base.metadata.create_all(bind=engine)

app = FastAPI()


def get_db():
db = SessionLocal()
try:
yield db
finally:
db.close()


# API

@app.get("/")
def root():
return {"message": "Hello World"}
Empty file added server/schemas/__init__.py
Empty file.
4 changes: 4 additions & 0 deletions server/schemas/submission.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from pydantic import BaseModel

class SubmissionBase(BaseModel):
...