I'm trying to select 3 variables in a sqlite3 statement. And putting this into 3 python variables, can't get it to work..
knifekingdb.execute("SELECT rank, rounds, date FROM knifekingdb WHERE steamid = ?", steamid)
I can put it into one list by assigning that statement to a python variabel. But i don't know how to split a list of integers and strings into different variabels.
Can you please help me, because i'm a bit stuck.
1 Answer 1
knifekingdb.execute(
"""SELECT rank, rounds, date
FROM knifekingdb WHERE steamid = ? LIMIT 1""", steamid)
try:
rank, rounds, date = knifekingdb.fetchone()
except TypeError:
# fetchone returned None because no row was found
# handle error here
raise
answered Dec 1, 2012 at 12:40
unutbu
887k197 gold badges1.9k silver badges1.7k bronze badges
Sign up to request clarification or add additional context in comments.
3 Comments
user1868569
Have to ask, why use 3 double qoutes?
unutbu
@user1868569: I find code is more readable when lines are no longer than ~80 characters. So used a multiline string for the SQL.
default