· 6 years ago · Mar 24, 2020, 07:28 PM
1import mysql.connector
2from api import *
3import sys
4
5
6sys.stdout = open('output.txt', 'w')
7sys.stderr = open('log.txt', 'w')
8
9
10database = mysql.connector.connect(host='bagdik.mysql.pythonanywhere-services.com', user='bagdik', password='', database='bagdik$marine')
11cursor = database.cursor(buffered=True)
12
13
14def db_init():
15 cursor.execute("DROP TABLE IF EXISTS members")
16 cursor.execute("CREATE TABLE IF NOT EXISTS members (id INT AUTO_INCREMENT PRIMARY KEY, user_id INT(10), ship VARCHAR(255), is_paid BOOLEAN)")
17 database.commit()
18
19
20
21confs = [2000000001, 2000000003, 2000000004, 2000000008, 2000000005, 2000000006, 2000000011,
22 2000000010, 2000000014, 2000000015, 2000000016, 2000000022]
23
24
25def fill():
26 sql = "INSERT INTO members (user_id, ship, is_paid) VALUES (%s, %s, %s)"
27 values = ('206281689', 'Grossadmiral', 0)
28 cursor.execute(sql, values)
29 for chat in confs:
30 if chat != 2000000001:
31 if chat == 2000000003:
32 name = 'Falke'
33 elif chat == 2000000005:
34 name = 'Esel'
35 elif chat == 2000000004:
36 name = 'Remilius'
37 elif chat == 2000000008:
38 name = 'Totenstille'
39 elif chat == 2000000011:
40 name = 'Monarch'
41 elif chat == 2000000006:
42 name = 'Hipper'
43 elif chat == 2000000010:
44 name = 'Scharnhorst'
45 elif chat == 2000000014:
46 name = 'Hohenzollern'
47 elif chat == 2000000015:
48 name = 'U-1349'
49 elif chat == 2000000016:
50 name = 'Nord'
51 elif chat == 2000000022:
52 name = 'Ost'
53 for user_id in get_convmembers(chat):
54 if not int(user_id) == 206281689:
55 values = (user_id, name, False)
56 cursor.execute(sql, values)
57 database.commit()
58
59
60def printall():
61 cursor.execute("SELECT * FROM members")
62 myresult = cursor.fetchall()
63 for x in myresult:
64 print(x)
65 for x in cursor:
66 print(x)