Skip to content

Commit

Permalink
add database name as the Connection attribute (#752)
Browse files Browse the repository at this point in the history
This change adds `self.database` as the Connection attribute
displaying the database name from connection parameters.

This is very useful for otel dbapi tracer.
  • Loading branch information
cazorla19 authored Jan 5, 2025
1 parent 207ac1a commit 8103651
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/MySQLdb/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ class object, used to create cursors (keyword only)
if type(k) is not int # noqa: E721
}

self.database = kwargs2.get("database", "")

self._server_version = tuple(
[numeric_part(n) for n in self.get_server_info().split(".")[:2]]
)
Expand Down

0 comments on commit 8103651

Please sign in to comment.