blob: 02b1e96624735646c6f4ede4801197c8591f69a4 [file] [log] [blame]
mbligh8bcd23a2009-02-03 19:14:06 +00001import common
mbligh96cf0512008-04-17 15:25:38 +00002import MySQLdb as driver
mblighb7c77d52007-12-03 19:04:39 +00003import db
Gabe Blackdf0beb32015-04-20 16:15:53 -07004from autotest_lib.client.common_lib.cros import retry
mblighb7c77d52007-12-03 19:04:39 +00005
6class db_mysql(db.db_sql):
Dan Shib7a36ea2017-02-28 21:52:20 -08007 @retry.retry(db._get_error_class("OperationalError"), timeout_min=10,
8 delay_sec=5)
Richard Barnette2468fbd2014-11-07 01:12:46 +00009 def connect(self, host, database, user, password, port):
10 connection_args = {
11 'host': host,
12 'user': user,
13 'db': database,
14 'passwd': password,
Allen Li02351772016-10-31 17:46:34 -070015 'connect_timeout': 20,
Richard Barnette2468fbd2014-11-07 01:12:46 +000016 }
17 if port:
18 connection_args['port'] = int(port)
19 return driver.connect(**connection_args)