forked from acm-ndsu/byte_le_engine
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Schemas, main database, main (#82)
- Loading branch information
1 parent
f0fe075
commit 50f297b
Showing
7 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import parsec | ||
import re | ||
|
||
from game.config import ALLOWED_MODULES | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from pydantic import BaseModel | ||
|
||
class SubmissionBase(BaseModel): | ||
... |