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 | 8684b92 | 2015-10-06 13:29:18 -0700 | [diff] [blame] | 7 | @retry.retry(db._get_error_class("OperationalError"), timeout_min=2, |
Gabe Black | df0beb3 | 2015-04-20 16:15:53 -0700 | [diff] [blame] | 8 | delay_sec=0.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, |
| 15 | } |
| 16 | if port: |
| 17 | connection_args['port'] = int(port) |
| 18 | return driver.connect(**connection_args) |