(Feb-28-2019, 05:56 PM)Larz60+ Wrote: Please post code in context.
The error is for line 23, you only have 4 lines.
That said, you are selecting version from the fourth item in row (row[3]).
Which if this is actually line 4, may be ok.
However, by the time you reach 23 (which we can't see) version may be out of scope, and we have no way of knowing this.
Please post enough code to show all code involved with the error.
This is the rest of the code.
from datetime import datetime import time import random import sqlite3 conn = sqlite3.connect('database.db') c = conn.cursor() ts = time.time() date = datetime.fromtimestamp(ts).strftime('%Y-%m-%d') time = datetime.fromtimestamp(ts).strftime('%H:%M:%S') namn = "david andersen" c.execute('SELECT * FROM tider WHERE Namn=? AND datum=?', [namn, date]) data = c.fetchall() for row in data: version = (row[3]) print (version)
Never mind i fixed it like this.
c.execute('SELECT * FROM tider WHERE Namn=? AND datum=?', (namn, date))