Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
tuple and formating problem
#1
Hi
Im using sqlite3 for a lite project and im getting this error

Error:
conn.execute('SELECT * FROM anställda WHERE ID={0},{1},{2},{3}'.format(uid[:4])) IndexError: tuple index out of range
i have no idea how to fix it. I think the fault lies in the formating or something. Could anyone take a look at the code and help pls.

    # Database  stuff
    #dataid = (uid[:4])
    conn.execute('SELECT * FROM anställda WHERE ID={0},{1},{2},{3}'.format(uid[:4]))
    data = cursor.fetchall()
    #print(data)
    for row in data:
        version = (row[0]) #<----siffran bestämmer column
        print(version)
Reply


Messages In This Thread
tuple and formating problem - by darktitan - Feb-17-2019, 05:44 PM
RE: tuple and formating problem - by marienbad - Feb-17-2019, 05:56 PM
RE: tuple and formating problem - by darktitan - Feb-17-2019, 06:22 PM
RE: tuple and formating problem - by marienbad - Feb-17-2019, 06:57 PM
RE: tuple and formating problem - by darktitan - Feb-17-2019, 07:09 PM
RE: tuple and formating problem - by marienbad - Feb-17-2019, 07:14 PM
RE: tuple and formating problem - by darktitan - Feb-17-2019, 07:24 PM
RE: tuple and formating problem - by marienbad - Feb-17-2019, 07:37 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Formating generated .data file to XML malcoverc 3 1,369 Apr-14-2022, 09:41 PM
Last Post: malcoverc
  propper formating paracelsusx 2 1,910 Jul-16-2021, 09:17 AM
Last Post: perfringo
  Adding graph points and formating project_science 4 2,407 Jan-24-2021, 05:02 PM
Last Post: project_science
  code with no tuple gets : IndexError: tuple index out of range Aggam 4 2,847 Nov-04-2020, 11:26 AM
Last Post: Aggam
  Excel: Apply formating of a sheet(file1) to another sheet(file2) lowermoon 1 2,058 May-26-2020, 07:57 AM
Last Post: buran
  How to get first line of a tuple and the third item in its tuple. Need Help, Anybody? SukhmeetSingh 5 3,219 May-21-2019, 11:39 AM
Last Post: avorane
  pymysql: formating ouput of query wardancer84 18 8,400 Oct-04-2018, 01:54 PM
Last Post: wardancer84
  Problem between list and tuple PierreSoulier 2 2,794 Jul-19-2018, 12:40 PM
Last Post: PierreSoulier
  Tuple Space with lindypy Problem draems 0 2,582 Sep-19-2017, 07:00 AM
Last Post: draems
  output formating mcmxl22 2 3,072 Jun-19-2017, 07:21 PM
Last Post: buran

Forum Jump:

User Panel Messages

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