Archived
1
0
Fork 0
This repository has been archived on 2024-06-28. You can view files and clone it, but cannot push or open issues or pull requests.
citybike/top.py
Lukas Winkler 5c6c1a43fe topListe
2016-10-05 14:25:28 +02:00

35 lines
599 B
Python

topSQL = {
"shortestConnections": """
SELECT
id,
s.name,
g.name,
length
FROM connections
LEFT JOIN stationen AS s ON start = s.ref
LEFT JOIN stationen AS g ON goal = g.ref
WHERE start != goal
ORDER BY length ASC
LIMIT 10
""",
"farAway": """
SELECT *
FROM (SELECT
name,
length,
ref
FROM connections
LEFT JOIN stationen ON (start = ref OR goal = ref)
WHERE start != goal
ORDER BY length ASC) AS x
GROUP BY ref
ORDER BY length DESC"""
}
def helloworld(cursor, top):
cursor.execute(topSQL[top])
return cursor.fetchall()