Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.

Commit 2ce1710

Browse files
pik94erezsh
authored andcommitted
Move SingleConnection class definition to create_connection function
1 parent c6dc301 commit 2ce1710

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

data_diff/databases/clickhouse.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
from typing import Optional, Type
22

3-
import clickhouse_driver.dbapi.connection
4-
53
from .base import (
64
MD5_HEXDIGITS,
75
CHECKSUM_HEXDIGITS,
@@ -20,13 +18,6 @@ def import_clickhouse():
2018
return clickhouse_driver
2119

2220

23-
class SingleConnection(clickhouse_driver.dbapi.connection.Connection):
24-
def cursor(self, cursor_factory=None):
25-
if not len(self.cursors):
26-
_ = super().cursor()
27-
return self.cursors[0]
28-
29-
3021
class Clickhouse(ThreadedDatabase):
3122
TYPE_CLASSES = {
3223
"Int8": Integer,
@@ -61,6 +52,15 @@ def __init__(self, *, thread_count: int, **kw):
6152

6253
def create_connection(self):
6354
clickhouse = import_clickhouse()
55+
56+
class SingleConnection(clickhouse.dbapi.connection.Connection):
57+
"""Not thread-safe connection to Clickhouse"""
58+
59+
def cursor(self, cursor_factory=None):
60+
if not len(self.cursors):
61+
_ = super().cursor()
62+
return self.cursors[0]
63+
6464
try:
6565
connection = SingleConnection(**self._args)
6666
return connection

0 commit comments

Comments
 (0)