Skip to content

Commit

Permalink
Implement roles support in sqlalchemy
Browse files Browse the repository at this point in the history
  • Loading branch information
mdesmet committed Sep 23, 2022
1 parent 75e6556 commit 9b9c848
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ engine = create_engine(
"session_properties": {'query_max_run_time': '1d'},
"client_tags": ["tag1", "tag2"],
"experimental_python_types": True,
"roles": {"catalog1": "role1"},
}
)

Expand All @@ -108,7 +109,8 @@ engine = create_engine(
'trino://user@localhost:8080/system?'
'session_properties={"query_max_run_time": "1d"}'
'&client_tags=["tag1", "tag2"]'
'&experimental_python_types=true',
'&experimental_python_types=true'
'&roles={"catalog1": "role1"}'
)
```

Expand Down
3 changes: 3 additions & 0 deletions trino/sqlalchemy/dialect.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ def create_connect_args(self, url: URL) -> Tuple[Sequence[Any], Mapping[str, Any
if "experimental_python_types" in url.query:
kwargs["experimental_python_types"] = json.loads(url.query["experimental_python_types"])

if "roles" in url.query:
kwargs["roles"] = json.loads(url.query["roles"])

return args, kwargs

def get_columns(self, connection: Connection, table_name: str, schema: str = None, **kw) -> List[Dict[str, Any]]:
Expand Down

0 comments on commit 9b9c848

Please sign in to comment.