File size: 506 Bytes
8e3435c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import sqlite3

# Create or connect to an SQLite3 database
conn = sqlite3.connect("db.sqlite3")  # This creates db.sqlite3 if it doesn't exist
cursor = conn.cursor()

# Create a sample table
cursor.execute('''

    CREATE TABLE IF NOT EXISTS users (

        id INTEGER PRIMARY KEY AUTOINCREMENT,

        name TEXT NOT NULL,

        email TEXT UNIQUE NOT NULL

    )

''')

# Commit changes and close connection
conn.commit()
conn.close()

print("Database and table created successfully!")