Skip to content

Commit

Permalink
add optional schema parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
zainhoda committed Oct 30, 2023
1 parent 4862898 commit ba090dc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "flit_core.buildapi"

[project]
name = "vanna"
version = "0.0.26"
version = "0.0.27"
authors = [
{ name="Zain Hoda", email="[email protected]" },
]
Expand Down
5 changes: 5 additions & 0 deletions src/vanna/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1834,6 +1834,7 @@ def connect_to_snowflake(
username: str,
password: str,
database: str,
schema: Union[str, None] = None,
role: Union[str, None] = None,
):
"""
Expand All @@ -1857,6 +1858,7 @@ def connect_to_snowflake(
username (str): The Snowflake username.
password (str): The Snowflake password.
database (str): The default database to use.
schema (Union[str, None], optional): The schema to use. Defaults to None.
role (Union[str, None], optional): The role to use. Defaults to None.
"""

Expand Down Expand Up @@ -1914,6 +1916,9 @@ def run_sql_snowflake(sql: str) -> pd.DataFrame:
cs.execute(f"USE ROLE {role}")
cs.execute(f"USE DATABASE {database}")

if schema is not None:
cs.execute(f"USE SCHEMA {schema}")

cur = cs.execute(sql)

results = cur.fetchall()
Expand Down

0 comments on commit ba090dc

Please sign in to comment.