Last active
January 20, 2023 07:00
-
-
Save samuelsaari/0299d2dbefc2120bfa7421c427e41b57 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sqlite3 | |
import os | |
os.chdir(os.path.dirname(__file__)) | |
print(os.getcwd()) | |
db = sqlite3.connect("bikes.db") | |
db.isolation_level = None | |
def distance_of_user(user): | |
count=db.execute(f''' | |
SELECT SUM(distance) | |
FROM Users LEFT JOIN Trips ON Users.id=Trips.user_id | |
WHERE Users.name={user} | |
''').fetchone() | |
return count | |
print("Test 1:", distance_of_user("user123")) | |
# print("Test 2:", speed_of_user("user123")) | |
# print("Test 3:", duration_in_each_city("2021-06-01")) | |
# print("Test 4:", users_in_city("city5")) | |
# print("Test 5:", trips_on_each_day("city5")) | |
# print("Test 6:", most_popular_start("city5")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment