From 346f3f819fcc3cd9c07a6b8668eff5a955c1d7e2 Mon Sep 17 00:00:00 2001 From: Kevin Smith Date: Wed, 11 Oct 2023 09:05:15 -0500 Subject: [PATCH] Add connection debugging --- setup.cfg | 2 +- singlestoredb/__init__.py | 2 +- singlestoredb/config.py | 7 +++++++ singlestoredb/mysql/_auth.py | 4 +++- singlestoredb/mysql/connection.py | 3 ++- singlestoredb/mysql/protocol.py | 3 ++- 6 files changed, 16 insertions(+), 5 deletions(-) diff --git a/setup.cfg b/setup.cfg index f47c4921..eaf83f85 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = singlestoredb -version = 0.7.1 +version = 0.7.2 description = Interface to the SingleStore database and cluster management APIs long_description = file: README.md long_description_content_type = text/markdown diff --git a/singlestoredb/__init__.py b/singlestoredb/__init__.py index bceb9795..a3cf75f8 100644 --- a/singlestoredb/__init__.py +++ b/singlestoredb/__init__.py @@ -13,7 +13,7 @@ """ -__version__ = '0.7.1' +__version__ = '0.7.2' from .config import options, get_option, set_option, describe_option from .connection import connect, apilevel, threadsafety, paramstyle diff --git a/singlestoredb/config.py b/singlestoredb/config.py index 99286cf6..55521619 100644 --- a/singlestoredb/config.py +++ b/singlestoredb/config.py @@ -230,3 +230,10 @@ 'Print queries and parameters to stderr.', environ='SINGLESTOREDB_DEBUG_QUERIES', ) + + +register_option( + 'debug.connection', 'bool', check_bool, False, + 'Print connection tracing information.', + environ='SINGLESTOREDB_DEBUG_CONNECTION', +) diff --git a/singlestoredb/mysql/_auth.py b/singlestoredb/mysql/_auth.py index 4778d317..106165fd 100644 --- a/singlestoredb/mysql/_auth.py +++ b/singlestoredb/mysql/_auth.py @@ -16,8 +16,10 @@ from functools import partial import hashlib +from ..config import get_option -DEBUG = False + +DEBUG = get_option('debug.connection') SCRAMBLE_LENGTH = 20 sha1_new = partial(hashlib.new, 'sha1') diff --git a/singlestoredb/mysql/connection.py b/singlestoredb/mysql/connection.py index 61a6affb..d668aa8b 100644 --- a/singlestoredb/mysql/connection.py +++ b/singlestoredb/mysql/connection.py @@ -46,6 +46,7 @@ LoadLocalPacketWrapper, ) from . import err +from ..config import get_option from ..connection import Connection as BaseConnection try: @@ -65,7 +66,7 @@ # KeyError occurs when there's no entry in OS database for a current user. DEFAULT_USER = None -DEBUG = False +DEBUG = get_option('debug.connection') TEXT_TYPES = { FIELD_TYPE.BIT, diff --git a/singlestoredb/mysql/protocol.py b/singlestoredb/mysql/protocol.py index 621add0b..bef4a4d0 100644 --- a/singlestoredb/mysql/protocol.py +++ b/singlestoredb/mysql/protocol.py @@ -5,13 +5,14 @@ import sys from . import err +from ..config import get_option from ..utils.results import Description from .charset import MBLENGTH from .constants import FIELD_TYPE from .constants import SERVER_STATUS -DEBUG = False +DEBUG = get_option('debug.connection') NULL_COLUMN = 251 UNSIGNED_CHAR_COLUMN = 251