Skip to content

Add DB-API instrumentor support for MySQL driver sqlcommenting #2897

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add test
  • Loading branch information
tammy-baylis-swi committed Oct 10, 2024
commit 385ea6c2b1ec445f1c5254b4625e0e8c0ac1cc68
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,33 @@ def test_executemany_mysqlclient_integration_comment(
r"Select 1 /\*db_driver='MySQLdb%%3A1.2.3',dbapi_threadsafety=123,driver_paramstyle='test',mysql_client_version='123',traceparent='\d{1,2}-[a-zA-Z0-9_]{32}-[a-zA-Z0-9_]{16}-\d{1,2}'\*/;",
)

def test_executemany_pymysql_integration_comment(self):
connect_module = mock.MagicMock()
connect_module.__name__ = "pymysql"
connect_module.__version__ = "1.2.3"
connect_module.apilevel = 123
connect_module.threadsafety = 123
connect_module.paramstyle = "test"
connect_module.get_client_info = mock.MagicMock(return_value="123")

db_integration = dbapi.DatabaseApiIntegration(
"testname",
"mysql",
enable_commenter=True,
commenter_options={"db_driver": True, "dbapi_level": False},
connect_module=connect_module,
)

mock_connection = db_integration.wrapped_connection(
mock_connect, {}, {}
)
cursor = mock_connection.cursor()
cursor.executemany("Select 1;")
self.assertRegex(
cursor.query,
r"Select 1 /\*db_driver='pymysql%%3A1.2.3',dbapi_threadsafety=123,driver_paramstyle='test',mysql_client_version='123',traceparent='\d{1,2}-[a-zA-Z0-9_]{32}-[a-zA-Z0-9_]{16}-\d{1,2}'\*/;",
)

def test_executemany_flask_integration_comment(self):
connect_module = mock.MagicMock()
connect_module.__name__ = "test"
Expand Down