diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-02-08 11:28:51 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-02-08 11:28:51 +0000 |
commit | 08cfba7d158632e4132e0cd8db31f9f3d2f541f0 (patch) | |
tree | 8f4d83701ee1eda863677685a1198a2a93dc94f0 /test/features/db_utils.py | |
parent | Adding upstream version 1.22.2. (diff) | |
download | mycli-08cfba7d158632e4132e0cd8db31f9f3d2f541f0.tar.xz mycli-08cfba7d158632e4132e0cd8db31f9f3d2f541f0.zip |
Adding upstream version 1.23.2.upstream/1.23.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/features/db_utils.py')
-rw-r--r-- | test/features/db_utils.py | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/test/features/db_utils.py b/test/features/db_utils.py index c29dedb..be550e9 100644 --- a/test/features/db_utils.py +++ b/test/features/db_utils.py @@ -1,11 +1,12 @@ import pymysql -def create_db(hostname='localhost', username=None, password=None, - dbname=None): +def create_db(hostname='localhost', port=3306, username=None, + password=None, dbname=None): """Create test database. :param hostname: string + :param port: int :param username: string :param password: string :param dbname: string @@ -14,6 +15,7 @@ def create_db(hostname='localhost', username=None, password=None, """ cn = pymysql.connect( host=hostname, + port=port, user=username, password=password, charset='utf8mb4', @@ -26,14 +28,15 @@ def create_db(hostname='localhost', username=None, password=None, cn.close() - cn = create_cn(hostname, password, username, dbname) + cn = create_cn(hostname, port, password, username, dbname) return cn -def create_cn(hostname, password, username, dbname): +def create_cn(hostname, port, password, username, dbname): """Open connection to database. :param hostname: + :param port: :param password: :param username: :param dbname: string @@ -42,6 +45,7 @@ def create_cn(hostname, password, username, dbname): """ cn = pymysql.connect( host=hostname, + port=port, user=username, password=password, db=dbname, @@ -52,11 +56,12 @@ def create_cn(hostname, password, username, dbname): return cn -def drop_db(hostname='localhost', username=None, password=None, - dbname=None): +def drop_db(hostname='localhost', port=3306, username=None, + password=None, dbname=None): """Drop database. :param hostname: string + :param port: int :param username: string :param password: string :param dbname: string @@ -64,6 +69,7 @@ def drop_db(hostname='localhost', username=None, password=None, """ cn = pymysql.connect( host=hostname, + port=port, user=username, password=password, db=dbname, |