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",
|
"request": "launch",
|
||||||
"module": "flask",
|
"module": "flask",
|
||||||
"env": {
|
"env": {
|
||||||
"FLASK_APP": "BreCal",
|
"FLASK_APP": "src/server/BreCal",
|
||||||
"FLASK_DEBUG": "1"
|
"FLASK_DEBUG": "1"
|
||||||
},
|
},
|
||||||
"args": [
|
"args": [
|
||||||
"run",
|
"run" //,
|
||||||
"--no-debugger",
|
// "--no-debugger",
|
||||||
"--no-reload"
|
//"--no-reload"
|
||||||
],
|
],
|
||||||
"jinja": true,
|
"jinja": true,
|
||||||
"justMyCode": 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.
|
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:
|
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
|
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 shipcalls
|
||||||
from .api import verify
|
from .api import verify
|
||||||
|
from .api import participant
|
||||||
|
from .api import times
|
||||||
|
from .api import notifications
|
||||||
|
|
||||||
|
|
||||||
def create_app(test_config=None):
|
def create_app(test_config=None):
|
||||||
@ -25,5 +28,8 @@ def create_app(test_config=None):
|
|||||||
# Add blueprints
|
# Add blueprints
|
||||||
app.register_blueprint(shipcalls.bp)
|
app.register_blueprint(shipcalls.bp)
|
||||||
app.register_blueprint(verify.bp)
|
app.register_blueprint(verify.bp)
|
||||||
|
app.register_blueprint(participant.bp)
|
||||||
|
app.register_blueprint(times.bp)
|
||||||
|
app.register_blueprint(notifications.bp)
|
||||||
|
|
||||||
return app
|
return app
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
import sys
|
||||||
import json
|
import json
|
||||||
import mariadb
|
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()
|
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:
|
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
|
# All the parameters are present in the options argument
|
||||||
|
|
||||||
return json.dumps({
|
return json.dumps({
|
||||||
"city": city,
|
|
||||||
"id": id,
|
"id": id,
|
||||||
|
"city": city,
|
||||||
"name": name,
|
"name": name,
|
||||||
"postal code": postal_code,
|
"postal code": postal_code,
|
||||||
"street": street,
|
"street": street,
|
||||||
}), 200
|
}), 200
|
||||||
|
|
||||||
|
return json.dumps([]), 200
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user