Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Challenge 6: Table Design | More About SQLite
SQL in Python Projects

Challenge 6: Table DesignChallenge 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 It is how code looks like text again
3. 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()

Which field should be the PRIMARY KEY?

Selecciona la respuesta correcta

¿Todo estuvo claro?

Sección 4. Capítulo 3
course content

Contenido del Curso

SQL in Python Projects

Challenge 6: Table DesignChallenge 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 It is how code looks like text again
3. 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()

Which field should be the PRIMARY KEY?

Selecciona la respuesta correcta

¿Todo estuvo claro?

Sección 4. Capítulo 3
some-alt