forked from moeheart/jx3bla
-
Notifications
You must be signed in to change notification settings - Fork 0
/
initDatabase.py
149 lines (125 loc) · 4.25 KB
/
initDatabase.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
import pymysql
import configparser
print("This operation is DANGEROUS!")
print("To continue, type 'yes':")
res = input()
if (res != "yes"):
exit
config = configparser.RawConfigParser()
config.readfp(open('./settings.cfg'))
name = config.get('jx3bla', 'username')
pwd = config.get('jx3bla', 'password')
db = pymysql.connect("127.0.0.1", name, pwd,"jx3bla",port=3306,charset='utf8mb4')
cursor = db.cursor()
cursor.execute("DROP TABLE IF EXISTS XiangZhiStat")
cursor.execute("DROP TABLE IF EXISTS ActorStat")
cursor.execute("DROP TABLE IF EXISTS PreloadInfo")
cursor.execute("DROP TABLE IF EXISTS HighestDps")
sql = """CREATE TABLE XiangZhiStat (
server VARCHAR(32),
id VARCHAR(32),
score INT,
battledate VARCHAR(32),
mapdetail VARCHAR(32),
edition VARCHAR(32),
hash VARCHAR(32) primary key,
statistics VARCHAR(16000),
public INT,
) DEFAULT CHARSET utf8mb4"""
cursor.execute(sql)
#在XiangZhiStat最后增加五个字段:editionfull INT, userid VARCHAR(32), battletime INT, submittime INT, instanceid VARCHAR(32)
sql = """CREATE TABLE ReplayProStat (
server VARCHAR(32),
id VARCHAR(32),
occ VARCHAR(32),
score INT,
battledate VARCHAR(32),
mapdetail VARCHAR(32),
boss VARCHAR(32),
hash VARCHAR(32) primary key,
shortID INT,
statistics MEDIUMBLOB,
public INT,
edition VARCHAR(32),
editionfull INT,
replayedition VARCHAR(32),
userid VARCHAR(32),
battletime INT,
submittime INT
) DEFAULT CHARSET utf8mb4"""
cursor.execute(sql)
# ReplayProStat表,支持更广泛形式的复盘数据
sql = """CREATE TABLE ReplayProInfo(
dataname VARCHAR(32),
datavalue VARCHAR(32),
datavalueint INT
) DEFAULT CHARSET utf8mb4"""
cursor.execute(sql)
sql = """INSERT INTO ReplayProInfo VALUES ("num", "", 0)"""
cursor.execute(sql)
# ReplayProInfo整体信息
sql = """CREATE TABLE ActorStat (
server VARCHAR(32),
boss VARCHAR(32),
battledate VARCHAR(32),
mapdetail VARCHAR(32),
edition VARCHAR(32),
hash VARCHAR(32) primary key,
statistics VARCHAR(16000)
) DEFAULT CHARSET utf8mb4"""
cursor.execute(sql)
#在ActorStat最后增加五个字段:editionfull INT, userid VARCHAR(32), battletime INT, submittime INT, instanceid VARCHAR(32)
sql = """CREATE TABLE PreloadInfo(
edition VARCHAR(32),
announcement VARCHAR(1024),
updateurl VARCHAR(1024),
) DEFAULT CHARSET utf8mb4"""
cursor.execute(sql)
sql = """CREATE TABLE HighestDps(
server VARCHAR(32),
player VARCHAR(32),
occ VARCHAR(32),
map VARCHAR(32),
boss VARCHAR(32),
dps INT
) DEFAULT CHARSET utf8mb4"""
cursor.execute(sql)
sql = """CREATE TABLE UserInfo(
uuid VARCHAR(32) primary key,
id VARCHAR(32),
mac VARCHAR(32),
ip VARCHAR(32),
regtime INT,
score INT,
exp INT
) DEFAULT CHARSET utf8mb4"""
cursor.execute(sql)
#在UserInfo最后增加11个字段:item(1-10) INT, lvl INT
sql = """CREATE TABLE ScoreInfo(
id VARCHAR(32),
userid VARCHAR(32),
time INT,
reason VARCHAR(128),
val INT) DEFAULT CHARSET utf8mb4"""
#新建一个表ScoreInfo,表示积分变动,记录scoreid,userid,时间,原因,变化量。
sql = """CREATE TABLE CommentInfo(
id VARCHAR(32),
server VARCHAR(32),
player VARCHAR(32),
userid VARCHAR(32),
mapdetail VARCHAR(32),
instanceid VARCHAR(32),
time INT,
type INT,
power INT,
content VARCHAR(1280),
pot VARCHAR(1280)) DEFAULT CHARSET utf8mb4"""
#新建一个表CommentInfo,用于收集评价,记录commentid,区服,玩家名,userid,时间,分类,等级,评论内容
sql = """CREATE TABLE InstanceInfo(
id VARCHAR(32),
server VARCHAR(32),
date VARCHAR(32),
cd VARCHAR(32)) DEFAULT CHARSET utf8mb4"""
#新建一个表InstanceInfo,表示副本信息,记录instanceid,区服,日期,副本ID。
db.commit()
db.close()