-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathquery_normalised.py
More file actions
26 lines (19 loc) · 919 Bytes
/
query_normalised.py
File metadata and controls
26 lines (19 loc) · 919 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import sqlite3
conn = sqlite3.connect("library.db")
cursor = conn.cursor()
def select_all_records_ordered_by_language_number(cursor):
print("All books ordered by language id and title:")
for row in cursor.execute("""SELECT language_code, author, title FROM books
ORDER BY language_code,title"""):
print(row)
def select_all_records_ordered_by_language_code(cursor):
print("All books ordered by language code and title:")
for row in cursor.execute(
"""SELECT languages.language_code, books.author, books.title
FROM books
JOIN languages ON (books.language_code = languages.id)
ORDER BY languages.language_code,title"""
):
print(row)
select_all_records_ordered_by_language_number(cursor)
select_all_records_ordered_by_language_code(cursor)