PADME Train Wiki
Train Selection
Search
Trains
SupplierRatingTest
820
main.py
Code fragments of main.py
import psycopg2
import os
conn = psycopg2.connect(database=os.environ["DB_NAME"], user=os.environ["DATA_SOURCE_USERNAME"], host=os.environ["DATA_SOURCE_HOST"], password=os.environ["DATA_SOURCE_PASSWORD"], port=os.environ["DATA_SOURCE_PORT"] )
conn = psycopg2.connect(database=os.environ["DB_NAME"], user=os.environ["DATA_SOURCE_USERNAME"], host=os.environ["DATA_SOURCE_HOST"], password=os.environ["DATA_SOURCE_PASSWORD"], port=os.environ["DATA_SOURCE_PORT"] )
cursor = conn.cursor()
cursor.execute("SELECT * FROM supplier_ratings")
ratings = cursor.fetchall()
# entry: (1, 'Supplier 2448', 'GmbH', 'In time', 20, 6, 456)
cnt_in_time = sum(1 for x in ratings if x[3] == "In time")
score = (100/ len(ratings)) * cnt_in_time
res = f"Score: {round(score, 2)}%"
print(res)
f = open("result.txt", "a")
f.write(f"{res}\n")
f.close()
Graph
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
main.py
import psycopg2
None
import os
conn = psycopg2.connect(database=os.environ["DB_NAME"], user=os.environ["DATA_SOURCE_USERNAME"], host=os.environ["DATA_SOURCE_HOST"], password=os.environ["DATA_SOURCE_PASSWORD"], port=os.environ["DATA_SOURCE_PORT"] )
cursor = conn.cursor()
cursor.execute("SELECT * FROM supplier_ratings")
ratings = cursor.fetchall()
# entry: (1, 'Supplier 2448', 'GmbH', 'In time', 20, 6, 456)
cnt_in_time = sum(1 for x in ratings if x[3] == "In time")
score = (100/ len(ratings)) * cnt_in_time
res = f"Score: {round(score, 2)}%"
print(res)
f = open("result.txt", "a")
f.write(f"{res}\n")
f.close()
Search
Train Selection