this works but i cant seem to get the other format to work
conn=sqlite3.connect("Jakson.db") ("Database Opened successfully") conn.execute('INSERT INTO SMITH(EXPIRE) VALUES (?)', [date_time])
i know that the date_time will work becasue ive already tested it on its own in a another database but i can seem to get this one to work
#conn=sqlite3.connect("Jakson.db") #print("Database Opened successfully") #conn.execute(""" #CREATE TABLE SMITH( #ADMIN_ID INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL , #EXPIRE DATE #) #""") import datetime import pytz import sqlite3 today = datetime.datetime.now() date_time = today.strftime("%m/%d/%Y") conn=sqlite3.connect("Jakson.db") ("Database Opened successfully") conn.execute('INSERT INTO SMITH VALUES (:ADMIN_ID, :EXPIRE)', { 'ADMIN_ID': None, 'EXPIRE':[date_time] })
InterfaceError: Error binding parameter :EXPIRE – probably unsupported type.
Advertisement
Answer
Use the following:
conn.execute('INSERT INTO SMITH VALUES (:ADMIN_ID, :EXPIRE)', { 'ADMIN_ID': None, 'EXPIRE': date_time })
[date_time] should be without brackets.