Python Forum
Python3 and sqlite3 using AND with SELECT
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python3 and sqlite3 using AND with SELECT
#3
(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))
Reply


Messages In This Thread
RE: Python3 and sqlite3 using AND with SELECT - by darktitan - Feb-28-2019, 07:01 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Gnuradio python3 is not compatible python3 xmlrpc library How Can I Fix İt ? muratoznnnn 3 5,109 Nov-07-2019, 05:47 PM
Last Post: DeaD_EyE
  SQL select join operation in python(Select.. join) pradeepkumarbe 1 2,357 Feb-14-2019, 08:34 PM
Last Post: woooee
  How retrieve sqlite3 database saved image and access in python3 tao01 1 2,545 Dec-22-2018, 09:04 PM
Last Post: Larz60+
  select one item from row with sqlite3 mcmxl22 1 2,482 Sep-24-2018, 01:08 AM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020