· 8 years ago · May 06, 2018, 08:46 PM
1#работа Ñ Ð±Ð´ - получение новых заданий, отмечание их - как принÑтые в работу
2
3import sqlite3
4import pymysql
5
6
7def make (op_id):
8 conn = pymysql.connect(host='mysql63.hostland.ru', charset="utf8", port=3306, user='host1629500_pylocall',
9 passwd='TCrq1SpH', db='host1629500')
10 myCursor = conn.cursor()
11
12
13 #Ñоздание таблицы
14 myCursor.execute(""" CREATE TABLE IF NOT EXISTS payment
15 (
16 id int primary key,
17 op_id varchar(40),
18 user_id varchar(40),
19 task_id varchar(40),
20 cost varchar(40),
21 date varchar(40)
22 )
23 """)
24
25
26 myCursor.execute('SELECT COUNT(*) FROM payment where (op_id) VALUES (?)', op_id)
27
28 a = myCursor.fetchone()
29 aa = a[0]
30
31 if aa < 1:
32 myCursor.execute("INSERT OR REPLACE INTO payment (op_id) VALUES (?)", op_id)
33 conn.commit()
34 conn.close()
35 else:
36 print("line exist")
37
38make("123456")
39
40
41
42
43
44def push(insta_url,cond):
45 conn = pymysql.connect(host='mysql63.hostland.ru', charset="utf8", port=3306, user='host1629500_pylocall',
46 passwd='TCrq1SpH', db='host1629500')
47 myCursor = conn.cursor()
48 myCursor.execute(""" UPDATE installid SET cond=%s WHERE installid.insta_url=%s """, (cond, insta_url))
49 conn.commit()
50 conn.close()
51
52
53
54def newTasksFreeLike():
55 list = []
56 conn = pymysql.connect(host='mysql63.hostland.ru', charset="utf8", port=3306, user='host1629500_pylocall',
57 passwd='TCrq1SpH', db='host1629500')
58 myCursor = conn.cursor()
59
60 myCursor.execute("SELECT * FROM installid WHERE cond = 'new';")
61 data = myCursor.fetchall()
62
63
64 i = 0
65
66 while i < len(data):
67 a = data[i]
68 linee = (a[2])
69 list.append(linee)
70 i = i + 1
71 conn.commit()
72 conn.close()
73 return list
74
75
76def put_inwork(list):
77 i = 0
78 while i < len(list):
79 push(list[i], "inwork")
80 i = i + 1
81
82
83
84
85
86#print(newTasks())
87#put_inwork (newTasks()) #пометить веÑÑŒ ÑпиÑок как принÑтый в работу