diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-02-18 19:15:17 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-02-18 19:15:48 +0300 |
commit | e1413bbc4716e63a89d281b931c2f30d4a7017cd (patch) | |
tree | 131b66009560e0a0c784ef7afcacb9d1713e2fcb /hercules | |
parent | 8baf09493f71df2f6ea81802748a638cbb8f6460 (diff) | |
download | evol-tools-e1413bbc4716e63a89d281b931c2f30d4a7017cd.tar.gz evol-tools-e1413bbc4716e63a89d281b931c2f30d4a7017cd.tar.bz2 evol-tools-e1413bbc4716e63a89d281b931c2f30d4a7017cd.tar.xz evol-tools-e1413bbc4716e63a89d281b931c2f30d4a7017cd.zip |
hercules: convert to char_reg_num_db.sql
Diffstat (limited to 'hercules')
-rw-r--r-- | hercules/code/server/db/charregnumdb.py | 32 | ||||
-rw-r--r-- | hercules/code/server/evol/main.py | 6 | ||||
-rw-r--r-- | hercules/templates/char_reg_num_db.sql | 9 |
3 files changed, 45 insertions, 2 deletions
diff --git a/hercules/code/server/db/charregnumdb.py b/hercules/code/server/db/charregnumdb.py new file mode 100644 index 0000000..b1446e3 --- /dev/null +++ b/hercules/code/server/db/charregnumdb.py @@ -0,0 +1,32 @@ +# -*- coding: utf8 -*- +# +# Copyright (C) 2015 Evol Online +# Author: Andrei Karas (4144) + +from code.fileutils import * +from code.stringutils import * + +def saveCharRegNumDbTable(users): + dstFile = "newdb/char_reg_num_db.sql" + firstLine = True + tpl = readFile("templates/char_reg_num_db.sql") + with open(dstFile, "w") as w: + w.write(tpl) + w.write("INSERT INTO `char_reg_num_db` VALUES ") + for userId in users: + user = users[userId] + for varKey in user.variables: + varValue = user.variables[varKey] + + if firstLine == False: + w.write(",\n") + else: + firstLine = False + + w.write(("({char_id},'{key}',{index},{value})").format( + char_id = user.char_id, + key = varKey, + index = "0", + value = varValue + )) + w.write("\n") diff --git a/hercules/code/server/evol/main.py b/hercules/code/server/evol/main.py index 6014e05..577c868 100644 --- a/hercules/code/server/evol/main.py +++ b/hercules/code/server/evol/main.py @@ -6,6 +6,7 @@ from code.server.account import * from code.server.db.char import * +from code.server.db.charregnumdb import * from code.server.evol.athena import * from code.server.evol.consts import * from code.server.evol.itemdb import * @@ -28,5 +29,6 @@ def serverEvolMain(): def dbEvolMain(): convertAccount() - users = readAthena(); - saveCharTable(users); + users = readAthena() + saveCharTable(users) + saveCharRegNumDbTable(users) diff --git a/hercules/templates/char_reg_num_db.sql b/hercules/templates/char_reg_num_db.sql new file mode 100644 index 0000000..dd96ae9 --- /dev/null +++ b/hercules/templates/char_reg_num_db.sql @@ -0,0 +1,9 @@ +CREATE TABLE IF NOT EXISTS `char_reg_num_db` ( + `char_id` INT(11) UNSIGNED NOT NULL DEFAULT '0', + `key` VARCHAR(32) BINARY NOT NULL DEFAULT '', + `index` INT(11) UNSIGNED NOT NULL DEFAULT '0', + `value` INT(11) NOT NULL DEFAULT '0', + PRIMARY KEY (`char_id`,`key`,`index`), + KEY `char_id` (`char_id`) +) ENGINE=InnoDB; + |