Skip to content

Commit

Permalink
SNOW-743102: fix create_engine("snowflake://").dialect (#387)
Browse files Browse the repository at this point in the history
  • Loading branch information
rooterkyberian authored Mar 14, 2023
1 parent 0d6ae47 commit 63e5e20
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/snowflake/sqlalchemy/snowdialect.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,11 @@ def create_connect_args(self, url):
raise sa_exc.ArgumentError(
f"Invalid name space is specified: {opts['database']}"
)
if ".snowflakecomputing.com" not in opts["host"] and not opts.get("port"):
if (
"host" in opts
and ".snowflakecomputing.com" not in opts["host"]
and not opts.get("port")
):
opts["account"] = opts["host"]
if "." in opts["account"]:
# remove region subdomain
Expand Down
11 changes: 11 additions & 0 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,17 @@ def test_connect_args():
engine.dispose()


def test_create_dialect():
"""
Tests getting only dialect object through create_engine
"""
engine = create_engine("snowflake://")
try:
assert engine.dialect
finally:
engine.dispose()


def test_simple_sql(engine_testaccount):
"""
Simple SQL by SQLAlchemy
Expand Down

0 comments on commit 63e5e20

Please sign in to comment.