1 Commits
Author SHA1 Message Date
Rudi 383ba32a2e Database basefiles
Base Datauen für die Datenbank
2026-08-22 23:57:48 +02:00
3 changed files with 43 additions and 52 deletions

No files matched your search

+7 -49
View File
@@ -1,21 +1,14 @@
# Tandur # Tandoor-Shoppinglist
Eine Website, die sich von einer selber gehosteten Tandoor-Instanz die Shoppinglist Einträge nimmt, und als Shoppinglist anzeigt. Eine Website, die sich von einer selber gehosteten Tandoor-Instanz die Shoppinglist Einträge nimmt, und als Shoppinglist anzeigt.
<div style="border-left: 4px solid #da3633; background-color: rgba(218, 54, 51, 0.1); padding: 12px 16px; border-radius: 0 6px 6px 0; margin: 16px 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;">
<div style="font-weight: 600; color: #f85149; margin-bottom: 4px; display: flex; align-items: center; gap: 8px;">
<span>⚠️</span> <strong>Just created</strong>
</div>
<div style="color: #c9d1d9; font-size: 14px;">
This Repository was just created. It isnt finished and under heavy construction. So this Service is unstable!
</div>
</div>
## Inhalt ## Inhalt
- TODO - TODO
- Festlegungen - Fsetlegungen
- Ablauf
- Installation
## TODO ## TODO
@@ -24,41 +17,6 @@ Eine Website, die sich von einer selber gehosteten Tandoor-Instanz die Shoppingl
- [ ] Next.js -> Frontend ? - [ ] Next.js -> Frontend ?
- [ ] Python -> Backend - [ ] Python -> Backend
- [ ] Implementieren - [ ] Implementieren
- [ ] README in English and German
## Festlegungen ## Festlegungen
- Database: SQLite3 mit sqlmodel *Hier muss noch beschrieben werden, wie genau das gemacht wird.*
- API FastAPI
- Jinja
- TailwindCSS + Alpine.js
???
## Ablauf
- Data fetch from Tandoor via APIs
- Data fetch from Database
- View on Website and edit
- Order vie Mail
- CSV download *optional
## Installation
### Bare metal
##### Linux
**Download and Setup**
```
git clone https://git.schamagusa.de/rudi/Tandur.git
cd Tandur
source .venv/bin/activate
#source .venv/bin/activate.fish #if you are using fish-shell
pip install --no-cache-dir -r requirements.txt
```
##### Run
```
uvicorn main:app
```
### Docker Compose (recomended)
#TODO
+23
View File
@@ -0,0 +1,23 @@
from typing import Optional
from sqlmodel import Field, SQLModel, create_engine, Session
# 1. Das Datenmodell (Tabelle in der DB)
class ShoppingItem(SQLModel, table=True):
id: Optional[int] = Field(default=None, primary_key=True)
name: str
menge: int = Field(default=1)
gekauft: bool = Field(default=False)
# 2. Die SQLite-Verbindung
# check_same_thread=False ist zwingend nötig für FastAPI + SQLite
sqlite_url = "sqlite:///tandur.db"
engine = create_engine(sqlite_url, connect_args={"check_same_thread": False})
# 3. Funktion zum Erstellen der Tabellen
def create_db_and_tables():
SQLModel.metadata.create_all(engine)
# 4. Session-Generator für die Routen
def get_session():
with Session(engine) as session:
yield session
+13 -3
View File
@@ -1,9 +1,19 @@
from fastapi import FastAPI, Request from contextlib import asynccontextmanager
from fastapi import FastAPI, Request, Depends
from fastapi.templating import Jinja2Templates from fastapi.templating import Jinja2Templates
from database import create_db_and_tables, get_session, ShoppingItem
from sqlmodel import Session
app = FastAPI() # Wird beim Starten des Servers exakt einmal ausgeführt
@asynccontextmanager
async def lifespan(app: FastAPI):
create_db_and_tables()
yield
app = FastAPI(lifespan=lifespan)
templates = Jinja2Templates(directory="templates") templates = Jinja2Templates(directory="templates")
@app.get("/") @app.get("/")
async def home(request: Request): async def home(request: Request, session: Session = Depends(get_session)):
# Hier können wir bald Daten aus der DB laden
return templates.TemplateResponse(request=request, name="index.html") return templates.TemplateResponse(request=request, name="index.html")