add database name as the Connection attribute (#752)

This change adds `self.database` as the Connection attribute
displaying the database name from connection parameters.

This is very useful for otel dbapi tracer.
This commit is contained in:
Mikhail Chinkov
2025-01-05 05:17:09 +01:00
committed by GitHub
parent 207ac1a948
commit 8103651bff

View File

@@ -204,6 +204,8 @@ class Connection(_mysql.connection):
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]]
)