Python Forum
[Tkinter] field in db as text
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] field in db as text
#1
Hi,

I am trying to get a field from db which is a text but when trying to print it it gives me in form of list. how to print the value as string instead!

        conn = sqlite3.connect('emsat_data.db')
        c = conn.cursor()
        c.execute("SELECT candidate_answer from candidate_math_answers where exam_photo=?", (thephoto[count - 1],))
        conn.commit()
        records = c.fetchall()
        theanswer=str(records[0])
        conn.close()
        print(theanswer)
note that the number of records is one record only that is why it is not in loop. When I try this code I get:
Quote:('A. 2',)
and what I want is
Quote:A. 2
Reply


Messages In This Thread
field in db as text - by rwahdan - Jul-15-2021, 08:25 AM
RE: field in db as text - by GOTO10 - Jul-15-2021, 11:40 AM
RE: field in db as text - by deanhystad - Jul-15-2021, 11:40 AM
RE: field in db as text - by rwahdan - Jul-15-2021, 01:38 PM
RE: field in db as text - by GOTO10 - Jul-15-2021, 01:53 PM
RE: field in db as text - by deanhystad - Jul-15-2021, 02:54 PM
RE: field in db as text - by rwahdan - Jul-16-2021, 07:07 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] Link text field to separate python file SMA 2 3,660 Mar-20-2017, 08:45 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

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