import sqlite3 # Connect to the database con = sqlite3.connect('database.db') # Create a cursor object cursor = con.cursor() # Define the data to be inserted as a list of tuples data = [ ('John Doe', 'johndoe@example.com'), ('Jane Smith', 'janesmith@example.com'), ('Mike Johnson', 'mikejohnson@example.com') ] # Use executemany() to insert the data into the "users" table cursor.executemany("INSERT INTO users (name, email) VALUES (?, ?)", data) # Commit the changes con.commit()
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter