提交 e37890df 编写于 作者: D Doug Farrell

Updating to address CircleCi errors.

上级 0ad8d990
......@@ -25,7 +25,9 @@ def get_temperature_data(filepath: str) -> Dict:
return data
def get_average_temp_by_date(date_string: str, temperature_data: Dict) -> float:
def get_average_temp_by_date(
date_string: str,
temperature_data: Dict) -> float:
"""
This function gets the average temperature for all the samples
taken by the students by date
......
......@@ -26,7 +26,7 @@ def get_average_temp_by_date(date_string, connection):
sql = """
SELECT
avg(value) as average
FROM temperature_data
FROM temperature_data
WHERE date between ? and ?
"""
result = cursor.execute(sql, (min_date, max_date)).fetchone()
......
......@@ -26,7 +26,7 @@ def get_total_number_of_books_by_publishers(connection, direction) -> List:
JOIN book_publisher bp on bp.publisher_id = p.publisher_id
JOIN book b on b.book_id = bp.book_id
GROUP BY publisher_name
ORDER BY total_books {direction};
ORDER BY total_books {direction};
"""
result = cursor.execute(sql).fetchall()
return result
......@@ -49,7 +49,7 @@ def get_total_number_of_authors_by_publishers(connection, direction) -> List:
JOIN author_publisher ap on p.publisher_id = ap.publisher_id
JOIN author a on ap.author_id = a.author_id
GROUP BY publisher_name
ORDER BY total_authors {direction};
ORDER BY total_authors {direction};
"""
result = cursor.execute(sql).fetchall()
return result
......
......@@ -175,20 +175,29 @@ def main():
# Connect to the database using SqlAlchemy
path = os.path.dirname(os.path.abspath(__file__))
sqlite_filepath = os.path.join(path, "../../build_data/data/author_book_publisher.db")
sqlite_filepath = os.path.join(
path,
"../../build_data/data/author_book_publisher.db"
)
engine = create_engine(f"sqlite:///{sqlite_filepath}")
Session = sessionmaker()
Session.configure(bind=engine)
session = Session()
# Get the total number of books printed by each publisher
total_books_by_publisher = get_total_number_of_books_by_publishers(session, "desc")
total_books_by_publisher = get_total_number_of_books_by_publishers(
session,
"desc"
)
for row in total_books_by_publisher:
print(f"Publisher: {row.name}, total books: {row.total_books}")
print()
# Get the total number of authors each publisher publishes
total_authors_by_publisher = get_total_number_of_authors_by_publishers(session, "desc")
total_authors_by_publisher = get_total_number_of_authors_by_publishers(
session,
"desc"
)
for row in total_authors_by_publisher:
print(f"Publisher: {row.name}, total authors: {row.total_authors}")
print()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册