def main(): ############parse and load config file############### parse_config(CONF_FILE) init_logging() mysql_host = Config.db_host + ":" + str(Config.db_port) db = torndb.Connection(host=mysql_host, database=Config.db_name, user=Config.db_user, password=Config.db_pass) GlobalVar.set_db_handle(db) #################init db const value################### TableSelectSql(GlobalVar.get_db_handle()) TableFields(GlobalVar.get_db_handle()) test_host(db)
def __init__(self): settings = dict(debug=True, ) handlers = [ (r"/", MainHandler), (r"/reader", ReaderHandler), (r"/book", BookHandler), (r"/borrow", BorrowHandler), ] mysql_host = Config.db_host + ":" + str(Config.db_port) self.db = torndb.Connection(host=mysql_host, database=Config.db_name, user=Config.db_user, password=Config.db_pass) GlobalVar.set_db_handle(self.db) super(Application, self).__init__(handlers, **settings)
def __init__(self): settings = dict( debug=True, ) handlers = [ (r"/", MainHandler), (r"/host", HostHandler), ] mysql_host = Config.db_host + ":" + str(Config.db_port) self.db = torndb.Connection( host=mysql_host, database=Config.db_name, user=Config.db_user, password=Config.db_pass ) GlobalVar.set_db_handle(self.db) super(Application,self).__init__(handlers,**settings)