Skip to content

Commit 152ca5b

Browse files
Add __repr__ to DqliteConnection
Debugging sessions and logs now show address/database/state instead of the default <...Connection object at 0x...>. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 90c8f2f commit 152ca5b

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/dqliteclient/connection.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,12 @@ def is_connected(self) -> bool:
108108
"""Check if connected."""
109109
return self._protocol is not None
110110

111+
def __repr__(self) -> str:
112+
state = "connected" if self._protocol is not None else "disconnected"
113+
return (
114+
f"<DqliteConnection address={self._address!r} database={self._database!r} {state}>"
115+
)
116+
111117
@property
112118
def in_transaction(self) -> bool:
113119
"""Check if a transaction is active."""

0 commit comments

Comments
 (0)