diff --git a/src/snowflake/sqlalchemy/snowdialect.py b/src/snowflake/sqlalchemy/snowdialect.py index 358dca58..3217ed20 100644 --- a/src/snowflake/sqlalchemy/snowdialect.py +++ b/src/snowflake/sqlalchemy/snowdialect.py @@ -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 diff --git a/tests/test_core.py b/tests/test_core.py index 48a0d900..288a211a 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -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