Skip to content

Commit c5a6af0

Browse files
committed
Update the Python MySQL connector
1 parent 4ca0bac commit c5a6af0

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

seleniumbase/core/mysql.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Wrapper for MySQL DB functions to make life easier.
33
"""
44

5+
import sys
56
import time
67
from seleniumbase import config as sb_config
78
from seleniumbase.config import settings
@@ -40,11 +41,21 @@ def __init__(self, database_env='test', conf_creds=None):
4041
count = 0
4142
while count < retry_count:
4243
try:
43-
self.conn = pymysql.connect(host=db_server,
44-
port=db_port,
45-
user=db_user,
46-
passwd=db_pass,
47-
db=db_schema)
44+
if sys.version_info[0] == 3 and sys.version_info[1] >= 6 or (
45+
sys.version_info[0] > 3):
46+
# PyMySQL 1.0.0 or above renamed the variables.
47+
self.conn = pymysql.connect(host=db_server,
48+
port=db_port,
49+
user=db_user,
50+
password=db_pass,
51+
database=db_schema)
52+
else:
53+
# PyMySQL 0.10.1 for Python 2.7 and Python 3.5
54+
self.conn = pymysql.connect(host=db_server,
55+
port=db_port,
56+
user=db_user,
57+
passwd=db_pass,
58+
db=db_schema)
4859
self.conn.autocommit(True)
4960
self.cursor = self.conn.cursor()
5061
return

0 commit comments

Comments
 (0)