Looking at this: Inserting multiple rows in a single SQL query?, one way would be to create a string that you insert in your command
contactlist = [
['Siemens, Harper', '323-4149'],
['Smith, Patti', '239-1212'],
['Jackson, Janet', '313-1352'],
['Manfredi, Ralph','872-2221'],
['Thompson, Bobby', '365-2622'],
['James, Lebron', '457-6223'],
['Ziegler, Zig', '667-1101'],
['Robbins, Tony', '329-2310']
]
str([tuple(i) for i in contactlist])[1:-1]
Prints
"('Siemens, Harper', '323-4149'), ('Smith, Patti', '239-1212'), ('Jackson, Janet', '313-1352'), ('Manfredi, Ralph', '872-2221'), ('Thompson, Bobby', '365-2622'), ('James, Lebron', '457-6223'), ('Ziegler, Zig', '667-1101'), ('Robbins, Tony', '329-2310')"
But looking at the Python docs that is not necessary. Consider this
full example: (https://docs.python.org/2/library/sqlite3.html):
import sqlite3
contactlist = [
['Siemens, Harper', '323-4149'],
['Smith, Patti', '239-1212'],
['Jackson, Janet', '313-1352'],
['Manfredi, Ralph','872-2221'],
['Thompson, Bobby', '365-2622'],
['James, Lebron', '457-6223'],
['Ziegler, Zig', '667-1101'],
['Robbins, Tony', '329-2310']
]
conn = sqlite3.connect('example.db')
c = conn.cursor()
# Delete table
c.execute('drop table if exists employees')
# Create table
c.execute('''CREATE TABLE employees
(name, number)''')
# Insert a row of data
c.executemany('INSERT INTO employees VALUES (?,?)', contactlist)
# or
# c.execute("INSERT INTO employees VALUES {}".format(str([tuple(i) for i in contactlist])[1:-1]))
conn.commit() # Commit the changes
conn.close()
The database now contains a table called employees with the following rows:
('Siemens, Harper', '323-4149')
('Smith, Patti', '239-1212')
('Jackson, Janet', '313-1352')
('Manfredi, Ralph', '872-2221')
('Thompson, Bobby', '365-2622')
('James, Lebron', '457-6223')
('Ziegler, Zig', '667-1101')
('Robbins, Tony', '329-2310')