Challenge: Table Design
Завдання
Swipe to start coding
You need to complete the code to create a table in an SQLite database named cars
. The table should contain four fields:
id
— a unique identifier for the car.brand
— the brand of the car.engine_capacity
— the engine capacity of the car.video_presentation
— a video presentation of the car.
Fill in the blanks in the SQL query by choosing the correct data types for each field.
Рішення
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import sqlite3
conn = sqlite3.connect("cars_info.db")
cursor = conn.cursor()
# Create a table named `cars` with the specified fields and data types
cursor.execute('''
CREATE TABLE IF NOT EXISTS cars (
id INTEGER PRIMARY KEY,
brand TEXT,
engine_capacity REAL,
video_presentation BLOB
)
''')
conn.commit() # save the changes
conn.close() # close the database connection
Все було зрозуміло?
Дякуємо за ваш відгук!
Секція 3. Розділ 3
single
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import sqlite3
conn = sqlite3.connect("cars_info.db")
cursor = conn.cursor()
# Create a table named `cars` with the specified fields and data types
cursor.execute('''
CREATE TABLE IF NOT EXISTS cars (
id ___,
brand ___,
engine_capacity ___,
video_presentation ___
)
''')
conn.commit() # save the changes
conn.close() # close the database connection
Запитати АІ
Запитати АІ
Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат