Cursos /
SQL in Python Projects
Challenge 6: Table Design
Complete all parts of the task in sequence
- 📁 Create a new project in PyCharm;
- 📝 Create a new python file;
- 📚 Import the
sqlite3
library; - 🗄 Create a new database;
- 🤚 Create a
cursor
; - 📄 Create a table named
cars
with the following fields:- id;
- brand;
- engine_capacity;
- video_presentation;
- 📄 Select the appropriate data types in the table field;
- 🗝 One of the fields must be
PRIMARY KEY
; - 🪖 Save the changes;
- 🔑 Close the database connection.
1. It is recommended to do ...
2. Some text
3. Use such method.
2. Some text
It is how code looks like
text again3. Use such method.
import sqlite3
# Create a new database
conn = sqlite3.connect('cars_info.db')
# Create a cursor
cursor = conn.cursor()
# Create a table named 'cars' with the specified fields and data types
cursor.execute('''
CREATE TABLE cars (
id INTEGER PRIMARY KEY,
brand TEXT,
engine_capacity REAL,
video_presentation BLOB
)
''')
# Save the changes
conn.commit()
# Close the database connection
conn.close()
¿Todo estuvo claro?
Sección 4. Capítulo 3
Contenido del Curso
SQL in Python Projects
1. Development Environment on Your PC
2. Introduction to SQLite
4. More About SQLite
SQL in Python Projects
Challenge 6: Table Design
Complete all parts of the task in sequence
- 📁 Create a new project in PyCharm;
- 📝 Create a new python file;
- 📚 Import the
sqlite3
library; - 🗄 Create a new database;
- 🤚 Create a
cursor
; - 📄 Create a table named
cars
with the following fields:- id;
- brand;
- engine_capacity;
- video_presentation;
- 📄 Select the appropriate data types in the table field;
- 🗝 One of the fields must be
PRIMARY KEY
; - 🪖 Save the changes;
- 🔑 Close the database connection.
1. It is recommended to do ...
2. Some text
3. Use such method.
2. Some text
It is how code looks like
text again3. Use such method.
import sqlite3
# Create a new database
conn = sqlite3.connect('cars_info.db')
# Create a cursor
cursor = conn.cursor()
# Create a table named 'cars' with the specified fields and data types
cursor.execute('''
CREATE TABLE cars (
id INTEGER PRIMARY KEY,
brand TEXT,
engine_capacity REAL,
video_presentation BLOB
)
''')
# Save the changes
conn.commit()
# Close the database connection
conn.close()
¿Todo estuvo claro?
Sección 4. Capítulo 3