diff --git a/src/DatabaseLibrary/connection_manager.py b/src/DatabaseLibrary/connection_manager.py index de76d53..ae547fe 100644 --- a/src/DatabaseLibrary/connection_manager.py +++ b/src/DatabaseLibrary/connection_manager.py @@ -97,7 +97,7 @@ def connect_to_database(self, dbapiModuleName=None, dbName=None, dbUsername=None if dbapiModuleName in ["MySQLdb", "pymysql"]: dbPort = dbPort or 3306 logger.info('Connecting using : %s.connect(db=%s, user=%s, passwd=%s, host=%s, port=%s, charset=%s) ' % (dbapiModuleName, dbName, dbUsername, dbPassword, dbHost, dbPort, dbCharset)) - self._dbconnection = db_api_2.connect(db=dbName, user=dbUsername, passwd=dbPassword, host=dbHost, port=dbPort, charset=dbCharset) + self._dbconnection = db_api_2.connect(db=dbName, user=dbUsername, passwd=dbPassword, host=dbHost, port=dbPort, charset='utf8mb4' or dbCharset) elif dbapiModuleName in ["psycopg2"]: dbPort = dbPort or 5432 logger.info('Connecting using : %s.connect(database=%s, user=%s, password=%s, host=%s, port=%s) ' % (dbapiModuleName, dbName, dbUsername, dbPassword, dbHost, dbPort)) @@ -106,7 +106,7 @@ def connect_to_database(self, dbapiModuleName=None, dbName=None, dbUsername=None dbPort = dbPort or 1433 dbDriver = dbDriver or "{SQL Server}" logger.info('Connecting using : %s.connect(DRIVER=%s;SERVER=%s:%s;DATABASE=%s;UID=%s;PWD=%s)' % (dbapiModuleName, dbDriver, dbHost, dbPort, dbName, dbUsername, dbPassword)) - self._dbconnection = db_api_2.connect('DRIVER=%s;SERVER=%s:%s;DATABASE=%s;UID=%s;PWD=%s' % ( dbDriver, dbHost, dbPort, dbName, dbUsername, dbPassword)) + self._dbconnection = db_api_2.connect('DRIVER=%s;SERVER=%s:%s;DATABASE=%s;UID=%s;PWD=%s;charset=%s' % (dbDriver, dbHost, dbPort, dbName, dbUsername, dbPassword, 'utf8mb4' or dbCharset)) elif dbapiModuleName in ["excel"]: logger.info( 'Connecting using : %s.connect(DRIVER={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DBQ=%s;ReadOnly=1;Extended Properties="Excel 8.0;HDR=YES";)' % ( diff --git a/test/resources/common.resource b/test/resources/common.resource index e85a7e4..6b78a1b 100644 --- a/test/resources/common.resource +++ b/test/resources/common.resource @@ -17,7 +17,6 @@ ${DB_PORT} 5432 ${DB_USER} db_user # used for MySQL via PyODBC only -${DB_CHARSET} ${None} ${DB_DRIVER} ODBC Driver 18 for SQL Server @@ -42,8 +41,7 @@ Connect To DB ... ${DB_PASS} ... ${DB_HOST} ... ${DB_PORT} - ... ${DB_CHARSET} - ... ${DB_DRIVER} + ... dbDriver=${DB_DRIVER} ELSE Connect To Database ... ${DB_MODULE} diff --git a/test/tests/common_tests/encoding.robot b/test/tests/common_tests/encoding.robot index ce8c03a..b7dd2d9 100644 --- a/test/tests/common_tests/encoding.robot +++ b/test/tests/common_tests/encoding.robot @@ -10,7 +10,7 @@ Test Teardown Drop Tables Person And Foobar *** Test Cases *** -Character In Values +Non ASCII Characters In Values Execute Sql String INSERT INTO person VALUES(1,'Jürgen','Gernegroß') ${results}= Query ... SELECT LAST_NAME FROM person WHERE FIRST_NAME='Jürgen'