How to connect to a SQLite database in Python?

82 views

How to connect to a SQLite database in Python?

How to connect to a SQLite database in Python?

solveurit24@gmail.com Changed status to publish February 13, 2025
0

Use sqlite3 module to perform database operations.

import sqlite3

conn = sqlite3.connect('mydatabase.db')
cursor = conn.cursor()
cursor.execute('''CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)''')
conn.commit()
conn.close()

solveurit24@gmail.com Changed status to publish February 13, 2025
0
You are viewing 1 out of 1 answers, click here to view all answers.