Insert many rows instead of one at the time in SQLite

I am inserting a lot of data into my SQLite database. The data is stored as a list of messages. Right now, I am looping through the list, and inserting message after message, however I should probably insert the whole list of messages at the same time. How would I do this? This is my current code:

con = lite.connect(databasepath)
con.isolation_level = None

with con:
    cur = con.cursor()  
    cur.execute('BEGIN TRANSACTION')  
    for i in range(0, len(messages)):
        lat_dd,long_ddd = pos2ddd(messages[i].latitude, messages[i].longitude)
        cur.execute("INSERT OR IGNORE INTO Message(unixtime, latitude , longitude, userid) VALUES(?,?,?,?)", 
            (timeStamps1[i], lat_dd, long_ddd, ord(messageType1[i].msgid), messageType1[i].userid))    

Source: python

Leave a Reply