· 8 years ago · May 06, 2018, 08:22 PM
1import pymysql
2
3
4def make (op_id):
5 conn = pymysql.connect(host='mysql77.hostland.ru', charset="utf8", port=3306, user='host17777777',
6 passwd='77777', db='host1777700')
7 myCursor = conn.cursor()
8
9
10 #Ñоздание таблицы
11 myCursor.execute(""" CREATE TABLE IF NOT EXISTS paymentlist
12 (
13 id int primary key,
14 op_id varchar(40),
15 user_id varchar(40),
16 task_id varchar(40),
17 cost varchar(40),
18 date varchar(40)
19 )
20 """)
21
22
23 myCursor.execute('SELECT COUNT(op_id = (?)) FROM paymentlist ;', op_id)
24
25 a = myCursor.fetchone()
26 aa = a[0]
27
28 if aa < 1:
29 myCursor.execute("INSERT OR REPLACE INTO paymentlist (op_id) VALUES (?)", op_id)
30 conn.commit()
31 conn.close()
32 else:
33 print("line exist")
34
35make("123456")