Discuss / Python / do like this

do like this

Topic source

在路上Ce

#1 Created at ... [Delete] [Delete and Lock User]
def get_score_in(low, high):
    conn = sqlite3.connect(db_file)
    cursor = conn.cursor()
    try:
        cursor.execute(f"select name from user where (score between {low} and {high}) order by score")
        values = cursor.fetchall()
    except:
        return []
    finally:
        cursor.close()
        conn.close()
    return [x[0] for x in values]

documents: 
https://www.tutorialspoint.com/sqlite/sqlite_select_query.htm
https://www.sqlite.org/lang_select.html


  • 1

Reply