erster Versuch Daten aus der DB zu laden erfolgreich
This commit is contained in:
parent
d130dc08b0
commit
b5c7a35e3d
8
.vscode/launch.json
vendored
8
.vscode/launch.json
vendored
@ -10,13 +10,13 @@
|
||||
"request": "launch",
|
||||
"module": "flask",
|
||||
"env": {
|
||||
"FLASK_APP": "BreCal",
|
||||
"FLASK_APP": "src/server/BreCal",
|
||||
"FLASK_DEBUG": "1"
|
||||
},
|
||||
"args": [
|
||||
"run",
|
||||
"--no-debugger",
|
||||
"--no-reload"
|
||||
"run" //,
|
||||
// "--no-debugger",
|
||||
//"--no-reload"
|
||||
],
|
||||
"jinja": true,
|
||||
"justMyCode": true
|
||||
|
||||
16
README.md
16
README.md
@ -4,9 +4,21 @@ ___
|
||||
|
||||
Projekt zur verbesserten Kommunikation der maritimen Partner bei Schiffsanläufen in Bremen.
|
||||
|
||||
## Requirements
|
||||
## Anforderungen
|
||||
|
||||
## Architektur
|
||||
|
||||
Die Architektur besteht aus einer Datenbank und einem in Python implementierten Backend, das eine API zu Verfügung stellt. Diese API ist als OpenAPI 3.0 spezifiziert.
|
||||
Die Anwendung selbst kommuniziert nur über diese API mit der Datenbank. Es sind damit unterschiedliche Anwendungsplattformen denkbar, etwa eine Web-, Mobile- oder Windows Desktop Anwendung.
|
||||
In dieser [Folie](docs/Architektur.pptx) ist ein Bild / Überblick enthalten.
|
||||
|
||||
Ein erster Gedanke des Datenbank-Layouts sieht folgendermaßen aus:
|
||||

|
||||
|
||||
## Entwicklung
|
||||
|
||||
### Postman
|
||||
|
||||
## Development
|
||||
|
||||
Zum Debuggen der Flask App verwende ich dieses Tutorial:
|
||||
https://code.visualstudio.com/docs/python/tutorial-flask#_create-a-project-environment-for-the-flask-tutorial
|
||||
|
||||
BIN
docs/datenbank.jpeg
Normal file
BIN
docs/datenbank.jpeg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 283 KiB |
@ -4,6 +4,9 @@ import os
|
||||
|
||||
from .api import shipcalls
|
||||
from .api import verify
|
||||
from .api import participant
|
||||
from .api import times
|
||||
from .api import notifications
|
||||
|
||||
|
||||
def create_app(test_config=None):
|
||||
@ -25,5 +28,8 @@ def create_app(test_config=None):
|
||||
# Add blueprints
|
||||
app.register_blueprint(shipcalls.bp)
|
||||
app.register_blueprint(verify.bp)
|
||||
app.register_blueprint(participant.bp)
|
||||
app.register_blueprint(times.bp)
|
||||
app.register_blueprint(notifications.bp)
|
||||
|
||||
return app
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import sys
|
||||
import json
|
||||
import mariadb
|
||||
|
||||
@ -8,13 +9,19 @@ def GetParticipant(options):
|
||||
|
||||
"""
|
||||
|
||||
conn = mariadb.connect(host="localhost", user="ds", password="kle1nes")
|
||||
try:
|
||||
conn = mariadb.connect(host="lager", user="ds", password="Gurkensalat48", database="bremen_calling")
|
||||
except mariadb.Error as e:
|
||||
print(f"Error connecting to the database: {e}")
|
||||
sys.exit(1)
|
||||
|
||||
cur = conn.cursor()
|
||||
|
||||
query = "SELECT p.id, p.name, p.street, p.postal_code, p.city, p.flags FROM participant p INNER JOIN user u WHERE u.participant_id = p.id AND u.id = {id} "
|
||||
id = options["user_id"]
|
||||
query = "SELECT p.id, p.name, p.street, p.postal_code, p.city, p.flags FROM participant p INNER JOIN user u WHERE u.participant_id = p.id AND u.id = %d "
|
||||
data = [id]
|
||||
cur.execute(query, data)
|
||||
|
||||
cur.execute(query)
|
||||
|
||||
for (id, name, street, postal_code, city, flags) in cur:
|
||||
|
||||
@ -22,12 +29,12 @@ def GetParticipant(options):
|
||||
# All the parameters are present in the options argument
|
||||
|
||||
return json.dumps({
|
||||
"city": city,
|
||||
"id": id,
|
||||
"city": city,
|
||||
"name": name,
|
||||
"postal code": postal_code,
|
||||
"street": street,
|
||||
}), 200
|
||||
|
||||
|
||||
return json.dumps([]), 200
|
||||
|
||||
|
||||
Reference in New Issue
Block a user