|
3 | 3 | conn = sqlite3.connect("library.db") |
4 | 4 | cursor = conn.cursor() |
5 | 5 |
|
6 | | -cursor.execute( |
7 | | - """CREATE TABLE languages |
| 6 | +cursor.execute("""CREATE TABLE languages |
8 | 7 | (id INTEGER PRIMARY KEY AUTOINCREMENT, |
9 | | - language_code VARCHAR(2))""" |
10 | | -) |
| 8 | + language_code VARCHAR(2))""") |
11 | 9 |
|
12 | | -cursor.execute( |
13 | | - """INSERT INTO languages (language_code) |
14 | | - VALUES ('de')""" |
15 | | -) |
| 10 | +cursor.execute("""INSERT INTO languages (language_code) |
| 11 | + VALUES ('de')""") |
16 | 12 |
|
17 | | -cursor.execute( |
18 | | - """INSERT INTO languages (language_code) |
19 | | - VALUES ('en')""" |
20 | | -) |
| 13 | +cursor.execute("""INSERT INTO languages (language_code) |
| 14 | + VALUES ('en')""") |
21 | 15 |
|
22 | | -cursor.execute( |
23 | | - """CREATE TABLE "temp" ( |
| 16 | +cursor.execute("""CREATE TABLE "temp" ( |
24 | 17 | "id" INTEGER, |
25 | 18 | "title" TEXT, |
26 | 19 | "language_code" INTEGER REFERENCES languages(id), |
|
29 | 22 | "license" TEXT, |
30 | 23 | "release_date" DATE, |
31 | 24 | PRIMARY KEY("id" AUTOINCREMENT) |
32 | | - )""" |
33 | | -) |
| 25 | + )""") |
34 | 26 |
|
35 | | -cursor.execute( |
36 | | - """INSERT INTO temp (title,language,author,license,release_date) |
37 | | - SELECT title,language,author,license,release_date FROM books""" |
38 | | -) |
| 27 | +cursor.execute("""INSERT INTO temp (title,language,author,license,release_date) |
| 28 | + SELECT title,language,author,license,release_date FROM books""") |
39 | 29 |
|
40 | | -cursor.execute( |
41 | | - """UPDATE temp |
| 30 | +cursor.execute("""UPDATE temp |
42 | 31 | SET language_code = 1 |
43 | | - WHERE language = 'de'""" |
44 | | -) |
| 32 | + WHERE language = 'de'""") |
45 | 33 |
|
46 | | -cursor.execute( |
47 | | - """UPDATE temp |
| 34 | +cursor.execute("""UPDATE temp |
48 | 35 | SET language_code = 2 |
49 | | - WHERE language = 'en'""" |
50 | | -) |
| 36 | + WHERE language = 'en'""") |
51 | 37 |
|
52 | 38 | # Only SQLite ≥ 3.35.0 allows DROP COLUMN; |
53 | 39 | # Only Python versions ≥ 3.8 released after 27 April 2021 will receive these or |
|
0 commit comments