mbligh | 8bcd23a | 2009-02-03 19:14:06 +0000 | [diff] [blame] | 1 | import common |
mbligh | 96cf051 | 2008-04-17 15:25:38 +0000 | [diff] [blame] | 2 | import MySQLdb as driver |
mbligh | b7c77d5 | 2007-12-03 19:04:39 +0000 | [diff] [blame] | 3 | import db |
Gabe Black | df0beb3 | 2015-04-20 16:15:53 -0700 | [diff] [blame] | 4 | from autotest_lib.client.common_lib.cros import retry |
mbligh | b7c77d5 | 2007-12-03 19:04:39 +0000 | [diff] [blame] | 5 | |
| 6 | class db_mysql(db.db_sql): |
Dan Shi | b7a36ea | 2017-02-28 21:52:20 -0800 | [diff] [blame] | 7 | @retry.retry(db._get_error_class("OperationalError"), timeout_min=10, |
| 8 | delay_sec=5) |
Richard Barnette | 2468fbd | 2014-11-07 01:12:46 +0000 | [diff] [blame] | 9 | def connect(self, host, database, user, password, port): |
| 10 | connection_args = { |
| 11 | 'host': host, |
| 12 | 'user': user, |
| 13 | 'db': database, |
| 14 | 'passwd': password, |
Allen Li | 0235177 | 2016-10-31 17:46:34 -0700 | [diff] [blame] | 15 | 'connect_timeout': 20, |
Richard Barnette | 2468fbd | 2014-11-07 01:12:46 +0000 | [diff] [blame] | 16 | } |
| 17 | if port: |
| 18 | connection_args['port'] = int(port) |
| 19 | return driver.connect(**connection_args) |