-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcorrect_id_adder.py
34 lines (26 loc) · 927 Bytes
/
correct_id_adder.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
import pymysql
def get_connect():
db = pymysql.connect(host='185.209.22.56',
user='r4khic_pc',
password='v0LBdb3mbhrqGNHA',
db='bet_machine',
charset='utf8',
autocommit=True)
cursor = db.cursor()
return cursor
def get_query(connection):
query = 'SELECT * FROM `wheel_results` ORDER BY `game_run_time` ASC'
connection.execute(query)
results = connection.fetchall()
query_for_update = 'UPDATE `wheel_results` SET `correct_id` = "%s" WHERE `wheel_results`.`id` = %s'
correct_id = 0
for result in results:
correct_id += 1
id = result[0]
connection.execute(query_for_update, (correct_id, id))
print('update successfully !')
def main():
connection = get_connect()
get_query(connection)
if __name__ == '__main__':
main()