Skip to content

Commit 5dff0fe

Browse files
committed
fix sqlalchemy
1 parent 4931183 commit 5dff0fe

File tree

7 files changed

+18
-31
lines changed

7 files changed

+18
-31
lines changed

cc_superset/engine.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class DatabendEngineSpec(BaseEngineSpec, BasicParametersMixin):
3535
"""
3636

3737
engine = "databend"
38+
engine_name = 'Databend Sqlalchemy'
3839

3940
time_secondary_columns = True
4041
time_groupby_inline = True

databend_sqlalchemy/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,5 @@
33

44
from databend_sqlalchemy.entry_points import validate_entrypoints
55

6-
driver_name = 'clickhousedb'
7-
8-
VERSION = (0, 1, 8)
6+
VERSION = (0, 2, 1)
97
__version__ = '.'.join(str(x) for x in VERSION)

databend_sqlalchemy/databend_dialect.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -235,16 +235,6 @@ def connect(self, *cargs, **cparams):
235235
# inherits the docstring from interfaces.Dialect.connect
236236
return self.dbapi.connect(*cargs, **cparams)
237237

238-
def create_connect_args(self, url):
239-
kwargs = {
240-
'db_url': 'databend://%s:%d/' % (url.host, url.port or 8000),
241-
'username': url.username,
242-
'password': url.password,
243-
'database': url.database,
244-
}
245-
kwargs.update(url.query)
246-
return ([url.database or 'default'], kwargs)
247-
248238
def _get_default_schema_name(self, connection):
249239
return connection.scalar("select currentDatabase()")
250240

databend_sqlalchemy/entry_points.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def validate_entrypoints():
1212
try:
1313
dist = pkg_resources.get_distribution('databend-sqlalchemy')
1414
except pkg_resources.DistributionNotFound:
15-
print ('\nDatabend Sqlalchemy package not found in this Python installation')
15+
print('\nDatabend Sqlalchemy package not found in this Python installation')
1616
return -1
1717
entry_map = dist.get_entry_map()
1818
print()
@@ -24,14 +24,14 @@ def validate_entrypoints():
2424
try:
2525
expected_eps.remove(name)
2626
except KeyError:
27-
print (f'\nUnexpected entry point {name} found')
27+
print(f'\nUnexpected entry point {name} found')
2828
return -1
2929
if expected_eps:
3030
print()
3131
for name in expected_eps:
32-
print (f'Did not find expected ep {name}')
32+
print(f'Did not find expected ep {name}')
3333
return -1
34-
print ('\nEntrypoints correctly installed')
34+
print('\nEntrypoints correctly installed')
3535
return 0
3636

3737

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ def read_version():
3737
packages=find_packages('.', exclude=['tests*']),
3838
python_requires='>=3.4, <4',
3939
install_requires=[
40-
'databend_py==0.3.5',
41-
'mysql.connector',
40+
'databend_py',
4241
'sqlalchemy',
4342
],
4443

@@ -84,5 +83,6 @@ def read_version():
8483

8584
entry_points={
8685
'sqlalchemy.dialects': ['databend = databend_sqlalchemy.databend_dialect:DatabendDialect'],
86+
'superset.db_engine_specs': ['databend = databend_sqlalchemy.cc_superset.engine:DatabendEngineSpec']
8787
},
8888
)

tests/integration/test_sqlalchemy_integration.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
import pytest
55
from sqlalchemy import create_engine, text
6-
from sqlalchemy.dialects import registry
76
from sqlalchemy.engine.base import Connection, Engine
87
from sqlalchemy.exc import OperationalError
98

@@ -12,13 +11,12 @@ class TestDatabendDialect:
1211
def test_set_params(
1312
self, username: str, password: str, database_name: str, host_port_name: str
1413
):
15-
print("sss")
16-
registry.register("databend", __name__, "databend_sqlalchemy.databend_dialect.DatabendDialect")
1714
engine = create_engine(
1815
f"databend://{username}:{password}@{host_port_name}/{database_name}"
1916
)
2017
connection = engine.connect()
2118
result = connection.execute(text("SELECT 1"))
19+
print(result)
2220
assert len(result.fetchall()) == 1
2321
engine.dispose()
2422

tests/unit/test_databend_dialect.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ def test_create_dialect(self, dialect: DatabendDialect):
3030
assert isinstance(dialect.type_compiler, DatabendTypeCompiler)
3131
assert dialect.context == {}
3232

33-
def test_create_connect_args_service_account(self, dialect: DatabendDialect):
34-
u = url.make_url(
35-
"databend://user:pass@localhost:8000/testdb?secure=false"
36-
)
37-
38-
result_list, result_dict = dialect.create_connect_args(u)
39-
assert result_dict["db_url"] == "databend://localhost:8000/"
40-
assert result_dict["database"] == "testdb"
41-
assert result_dict["username"] == "user"
33+
# def test_create_connect_args_service_account(self, dialect: DatabendDialect):
34+
# u = url.make_url(
35+
# "databend://user:pass@localhost:8000/testdb?secure=false"
36+
# )
37+
#
38+
# result_list, result_dict = dialect.create_connect_args(u)
39+
# assert result_dict["db_url"] == "databend://localhost:8000/"
40+
# assert result_dict["database"] == "testdb"
41+
# assert result_dict["username"] == "user"
4242

4343
def test_do_execute(
4444
self, dialect: DatabendDialect, cursor: mock.Mock(spec=MockCursor)

0 commit comments

Comments
 (0)