-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestdb.py
36 lines (29 loc) · 807 Bytes
/
testdb.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import sqlite3
def create_connection(db_file):
""" create a database connection to the SQLite database
specified by the db_file
:param db_file: database file
:return: Connection object or None
"""
conn = None
try:
conn = sqlite3.connect(db_file)
except error as e:
print(e)
return conn
def select_all_tasks(conn):
"""
Query all rows in the tasks table
:param conn: the Connection object
:return:
"""
cur = conn.cursor()
cur.execute("SELECT name, astTo FROM player WHERE astTo < 100000 ORDER BY astTo DESC LIMIT 10")
rows = cur.fetchall()
for row in rows:
print(row)
def main():
connection = create_connection("players.db")
select_all_tasks(connection)
if __name__ == "__main__":
main()