Add precommit and basic sqlalchemy setup

This commit is contained in:
Joey Yakimowich-Payne 2023-08-09 11:00:55 -06:00
commit 1bbaef1c60
No known key found for this signature in database
GPG key ID: 6BFE655FA5ABD1E1
7 changed files with 285 additions and 2 deletions

Binary file not shown.

3
api/db/engine.py Normal file
View file

@ -0,0 +1,3 @@
from sqlalchemy import create_engine
engine = create_engine("sqlite+pysqlite:///:memory:", echo=True)

19
api/db/models.py Normal file
View file

@ -0,0 +1,19 @@
from typing import List
from typing import Optional
from sqlalchemy import ForeignKey
from sqlalchemy import String
from sqlalchemy.orm import DeclarativeBase
from sqlalchemy.orm import Mapped
from sqlalchemy.orm import mapped_column
from sqlalchemy.orm import relationship
from .engine import engine
class Base(DeclarativeBase):
pass
def create_tables():
Base.metadata.create_all(engine)

View file

@ -1,7 +1,9 @@
from db.engine import engine
from fastapi import FastAPI
app = FastAPI()
@app.get("/api/python")
def hello_world():
return {"message": "Hello World"}
return {"message": "Hello World"}