python: create and update a datetime field in a sqlite db
Question: I have a data structure that I'm iterating through:

    
    
    SomeList = [[ID, VarA, VarB, DateC, VarD],[ID2, VarA2, VarB2, DateC2, VarD2]...]
    

The DateCX variables will always be of the form:

    
    
    "2013-07-15T13:58:55Z" 
    

I've also used the `sqlite` library to create a sqlite database:

    
    
    import sqlite3 as lite
    con = lite.connect('test.db')
    with con:
        cur = con.cursor()
        cur.execute("CREATE TABLE TEST(ColumnID INT, ColumnA TEXT, ColumnB TEXT, ColumnC DATETIME, Column D TEXT)")
    

I'm then iterating through `SomeList`:

    
    
    for list in SomeList:
        TempID = list[0]
        TempA = list[1]
        TempB = list[2]
        TempDateC = list[3]
        TempD = list[4]
    

For the date field, I've been leveraging the `strptime` function in the `time`
library to parse it in python:

    
    
        TempDateC = time.strptime(TempDateC, "%Y-%m-%dT%H:%M:%SZ")
    

which results in the tuple that I'm expecting.

I then tried to update the `TEST` database:

    
    
        allValues = (TempID, TempA, TempB, TempDateC, TempD)
        cur.execute("INSERT INTO TEST VALUES(?, ?, ?, ?, ?)", allValues)
    

but I'm getting the following error:

    
    
     sqlite3.InterfaceError: Error binding parameter 3 - probably unsupported type.
    

Is there something else that I have to do to convert the tuple I've created
into something that can be inserted into a SQL db?


Answer: Okay, I figured it out.

You have to

    
    
    import time
    import datetime
    

and then, rather than

    
    
    TempDateC = time.strptime(TempDateC, "%Y-%m-%dT%H:%M:%SZ")
    

you need to parse the date with a few functions:

    
    
    TempDateC = datetime.datetime.fromtimestamp(time.mktime(time.strptime(TempdateC, "%Y-%m-%dT%H:%M:%SZ")))
    

