prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  SQLAlchemy executemany not detected in hooks
  In the Django ORM integration, we record `executemany` calls as the `SQL/Many` operation, but this is missing in the SQLAlchemy integration.
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `src/scout_apm/sqlalchemy.py`
  Content:
  ```
  1 # coding=utf-8
  2 from __future__ import absolute_import, division, print_function, unicode_literals
  3 
  4 from sqlalchemy import event
  5 
  6 from scout_apm.core.tracked_request import TrackedRequest
  7 
  8 
  9 def before_cursor_execute(conn, cursor, statement, parameters, context, executemany):
  10     tracked_request = TrackedRequest.instance()
  11     span = tracked_request.start_span(operation="SQL/Query")
  12     span.tag("db.statement", statement)
  13 
  14 
  15 def after_cursor_execute(conn, cursor, statement, parameters, context, executemany):
  16     tracked_request = TrackedRequest.instance()
  17     span = tracked_request.current_span()
  18     if span is not None:
  19         tracked_request.callset.update(statement, 1, span.duration())
  20         if tracked_request.callset.should_capture_backtrace(statement):
  21             span.capture_backtrace()
  22     tracked_request.stop_span()
  23 
  24 
  25 def instrument_sqlalchemy(engine):
  26     if getattr(engine, "_scout_instrumented", False):
  27         return
  28     event.listen(engine, "before_cursor_execute", before_cursor_execute)
  29     event.listen(engine, "after_cursor_execute", after_cursor_execute)
  30     engine._scout_instrumented = True
  31
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/src/scout_apm/sqlalchemy.py b/src/scout_apm/sqlalchemy.py
  --- a/src/scout_apm/sqlalchemy.py
  +++ b/src/scout_apm/sqlalchemy.py
  @@ -7,8 +7,12 @@
   
   
   def before_cursor_execute(conn, cursor, statement, parameters, context, executemany):
  +    if executemany:
  +        operation = "SQL/Many"
  +    else:
  +        operation = "SQL/Query"
       tracked_request = TrackedRequest.instance()
  -    span = tracked_request.start_span(operation="SQL/Query")
  +    span = tracked_request.start_span(operation=operation)
       span.tag("db.statement", statement)
  
verification_info: {"golden_diff": "diff --git a/src/scout_apm/sqlalchemy.py b/src/scout_apm/sqlalchemy.py\n--- a/src/scout_apm/sqlalchemy.py\n+++ b/src/scout_apm/sqlalchemy.py\n@@ -7,8 +7,12 @@\n \n \n def before_cursor_execute(conn, cursor, statement, parameters, context, executemany):\n+    if executemany:\n+        operation = \"SQL/Many\"\n+    else:\n+        operation = \"SQL/Query\"\n     tracked_request = TrackedRequest.instance()\n-    span = tracked_request.start_span(operation=\"SQL/Query\")\n+    span = tracked_request.start_span(operation=operation)\n     span.tag(\"db.statement\", statement)\n", "issue": "SQLAlchemy executemany not detected in hooks\nIn the Django ORM integration, we record `executemany` calls as the `SQL/Many` operation, but this is missing in the SQLAlchemy integration.\n", "before_files": [{"content": "# coding=utf-8\nfrom __future__ import absolute_import, division, print_function, unicode_literals\n\nfrom sqlalchemy import event\n\nfrom scout_apm.core.tracked_request import TrackedRequest\n\n\ndef before_cursor_execute(conn, cursor, statement, parameters, context, executemany):\n    tracked_request = TrackedRequest.instance()\n    span = tracked_request.start_span(operation=\"SQL/Query\")\n    span.tag(\"db.statement\", statement)\n\n\ndef after_cursor_execute(conn, cursor, statement, parameters, context, executemany):\n    tracked_request = TrackedRequest.instance()\n    span = tracked_request.current_span()\n    if span is not None:\n        tracked_request.callset.update(statement, 1, span.duration())\n        if tracked_request.callset.should_capture_backtrace(statement):\n            span.capture_backtrace()\n    tracked_request.stop_span()\n\n\ndef instrument_sqlalchemy(engine):\n    if getattr(engine, \"_scout_instrumented\", False):\n        return\n    event.listen(engine, \"before_cursor_execute\", before_cursor_execute)\n    event.listen(engine, \"after_cursor_execute\", after_cursor_execute)\n    engine._scout_instrumented = True\n", "path": "src/scout_apm/sqlalchemy.py"}], "after_files": [{"content": "# coding=utf-8\nfrom __future__ import absolute_import, division, print_function, unicode_literals\n\nfrom sqlalchemy import event\n\nfrom scout_apm.core.tracked_request import TrackedRequest\n\n\ndef before_cursor_execute(conn, cursor, statement, parameters, context, executemany):\n    if executemany:\n        operation = \"SQL/Many\"\n    else:\n        operation = \"SQL/Query\"\n    tracked_request = TrackedRequest.instance()\n    span = tracked_request.start_span(operation=operation)\n    span.tag(\"db.statement\", statement)\n\n\ndef after_cursor_execute(conn, cursor, statement, parameters, context, executemany):\n    tracked_request = TrackedRequest.instance()\n    span = tracked_request.current_span()\n    if span is not None:\n        tracked_request.callset.update(statement, 1, span.duration())\n        if tracked_request.callset.should_capture_backtrace(statement):\n            span.capture_backtrace()\n    tracked_request.stop_span()\n\n\ndef instrument_sqlalchemy(engine):\n    if getattr(engine, \"_scout_instrumented\", False):\n        return\n    event.listen(engine, \"before_cursor_execute\", before_cursor_execute)\n    event.listen(engine, \"after_cursor_execute\", after_cursor_execute)\n    engine._scout_instrumented = True\n", "path": "src/scout_apm/sqlalchemy.py"}]}