#! coding: utf8
import re, os, glob
import mysql.connector
from StringIO import StringIO
from client import Client
from logger import configure_logger
from dbc.spell import Spell
from dbc.journal import Journal
from config.connection import db_config

class DBFilesClient:
    def __init__(self, build_number, locale='zhCN'):
        self.build_number = build_number
        self.locale = locale
        self.con = mysql.connector.connect(**db_config)
        self.logger = configure_logger()
        
        # return row as dict
        self.cur = self.con.cursor(dictionary=True, buffered=True)
        
    def __del__(self):
        self.cur.close()
        self.con.close()
        
    def Spell(self, spell_id):
        return Spell(spell_id, self.cur, self.logger)
        
    def Journal(self, difficulty_id):
        return Journal(self.cur, self.logger, difficulty_id=difficulty_id)

@@ -591,16 +591,126 @@
 d=True)%0A
+        self.cur.execute('use %60%7Bself.build_number%7D_%7Bself.locale%7D%60'.format(%0A            self = self%0A        ))%0A
         

fix db selection