Add precommit and basic sqlalchemy setup
This commit is contained in:
parent
92d864773a
commit
1bbaef1c60
7 changed files with 285 additions and 2 deletions
Binary file not shown.
3
api/db/engine.py
Normal file
3
api/db/engine.py
Normal 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
19
api/db/models.py
Normal 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)
|
||||
|
|
@ -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"}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue