Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Challenge 1: First table | Introduction to SQLite
SQL in Python Projects

Challenge 1: First tableChallenge 1: First table

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 articles with the following fields:
  • 🪖 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 the sqlite3 library
import sqlite3
    
# Create a new database (or connect to an existing one)
connection = sqlite3.connect("my_database.db")
    
# Create a cursor
cursor = connection.cursor()
    
# Create a table named "articles" with the specified fields
    cursor.execute('''
        CREATE TABLE articles (
            id INTEGER,
            title TEXT,
            content TEXT,
            author TEXT
        )
    ''')
# Save the changes and close the database connection
connection.commit()
connection.close()
      

Все було зрозуміло?

Секція 2. Розділ 5
course content

Зміст курсу

SQL in Python Projects

Challenge 1: First tableChallenge 1: First table

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 articles with the following fields:
  • 🪖 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 the sqlite3 library
import sqlite3
    
# Create a new database (or connect to an existing one)
connection = sqlite3.connect("my_database.db")
    
# Create a cursor
cursor = connection.cursor()
    
# Create a table named "articles" with the specified fields
    cursor.execute('''
        CREATE TABLE articles (
            id INTEGER,
            title TEXT,
            content TEXT,
            author TEXT
        )
    ''')
# Save the changes and close the database connection
connection.commit()
connection.close()
      

Все було зрозуміло?

Секція 2. Розділ 5
some-alt