'using python I'm trying to insert ADMIN_ID as None in to a database in SQL and my date_time that converted into a suitable format into a table
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.
Solution 1:[1]
conn.execute('INSERT INTO SMITH VALUES (:ADMIN_ID, :EXPIRE)',
{
'ADMIN_ID': None,
'EXPIRE': date_time
})
figure it out had to remove the brackets [date_time]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Namd |
