blob: 5b88f4afc99603ba0af428f012c99475cc369a46 [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 Shi8684b922015-10-06 13:29:18 -07007 @retry.retry(db._get_error_class("OperationalError"), timeout_min=2,
Gabe Blackdf0beb32015-04-20 16:15:53 -07008 delay_sec=0.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,
15 }
16 if port:
17 connection_args['port'] = int(port)
18 return driver.connect(**connection_args)