1import common 2import MySQLdb as driver 3import db 4from autotest_lib.client.common_lib.cros import retry 5 6class db_mysql(db.db_sql): 7 @retry.retry(db._get_error_class("OperationalError"), timeout_min=2, 8 delay_sec=0.5) 9 def connect(self, host, database, user, password, port): 10 connection_args = { 11 'host': host, 12 'user': user, 13 'db': database, 14 'passwd': password, 15 } 16 if port: 17 connection_args['port'] = int(port) 18 return driver.connect(**connection_args) 19