def connect( self, db_name, db_user, db_pass, db_address='127.0.0.1', db_port=3306): self.db_name = db_name self.db_user = db_user self.db_pass = db_pass if db_port != 3306: self.db_address = '%s:%s' %(db_address,db_port) else: self.db_address = db_address self.connection = database.connect(db = db_name, user = db_user, passwd = db_pass, host = db_address) #, port = db_port) self.connection.set_charset('utf8') self.connection.set_unicode(True)
def connect(self, db_name, db_user, db_pass, db_address='127.0.0.1', db_port=3306): self.db_name = db_name self.db_user = db_user self.db_pass = db_pass if db_port != 3306: self.db_address = '%s:%s' % (db_address, db_port) else: self.db_address = db_address self.connection = database.connect(db=db_name, user=db_user, passwd=db_pass, host=db_address) #, port = db_port) self.connection.set_charset('utf8') self.connection.set_unicode(True)
def connect(self, db_name, *args): self.db_name = db_name self.connection = database.connect(db_name) self.connection.text_factory = unicode