bobo1234too
bobo1234too

Reputation: 21

How to read raw data from sqlite table

I am trying to save and load data for my discord bot using a sqlite database. After successfully saving and then selecting the data I went to compare the value and to see if the guild that I saved and the guild that I'm on are the same (which they were), but it wouldn't come out as true.

Inputting the data

 guild = ctx.guild.id
 cursor.execute("INSERT INTO counting (guild, currentnumber, lastuser, highscore, channelname) VALUES (?, 1, 0, 0, ?)",(guild, str(channelname)))
 connection.commit()

guild = 827994470023692358

Selecting the data and printing it

   guild = message.guild.id
   cursor.execute("SELECT guild FROM counting WHERE guild = ?", (guild,))
   data = cursor.fetchall()
   print(data)

Output:

[(869366856908169237,)]

How do I remove the [(,)] from the variable so later on I can compare the value

Upvotes: 0

Views: 323

Answers (1)

pigeonburger
pigeonburger

Reputation: 736

Access it by providing an index to the item you want to isolate:

print(data[0][0])

It's just a tuple inside a list.

Upvotes: 2

Related Questions