First week programming in any language and need some help: Im trying to extract a TEXT value as a string from sqlite3 in Python. Im getting a value as a list not a str:
system_id = raw_input ("What is your System ID: ")
For example the user enters 'Elmer'
conn = sqlite3.connect("API.db")
c = conn.cursor()
c.execute('''CREATE TABLE IF NOT EXISTS SYSTEMID (systemid TEXT)''')
conn.commit()
conn.close()
conn = sqlite3.connect("API.db")
c = conn.cursor()
system_id = c.execute('select systemid from SYSTEMID').fetchall()
conn.close()
So how to make the variable system_id as a string? If I print from this I get something like [(u, Elmer)], I want system_id = Elmer
fetchall()that returns alistof tuples. The problem is not the variable type. Print the currentsystem_idand you will see. Then depending on what you actually need, you can do something like:system_id = system_id[0][0]i guess..select systemid from SYSTEMID where user = "Elmer"