My goal is to take two variables, xdate and xtime and store them into an sqlite database in two separate columns using a python scripts. My code is
from datetime import datetime import sqlite3 as mydb import sys con = mydb.connect('testTime.db') def logTime(): i=datetime.now() xdate = i.strftime('%Y-%m-%d') xtime = i.strftime('%H-%M-%S') return xdate, xtime z=logTime() this is where I get hung up I tried
try: with con: cur = con.cursor cur.execute('INSERT INTO DT(Date, Time) Values (?,?)' (z[0],z[1])) data = cur.fetchone() print (data) con.commit() except: with con: cur=con.cursor() cur.execute("CREATE TABLE DT(Date, Time)') cur.commit() I keep getting none when I try to fetch the data.
Any tips or recommended readings??