0

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.

asked Dec 1, 2012 at 11:56

1 Answer 1

2
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
Sign up to request clarification or add additional context in comments.

3 Comments

Have to ask, why use 3 double qoutes?
@user1868569: you use triple quotes for multiline strings.
@user1868569: I find code is more readable when lines are no longer than ~80 characters. So used a multiline string for the SQL.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.