Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(oracle): support connection using oracle connection string #9435

Merged
merged 1 commit into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion ibis/backends/oracle/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from functools import cached_property
from operator import itemgetter
from typing import TYPE_CHECKING, Any
from urllib.parse import urlparse

import numpy as np
import oracledb
Expand Down Expand Up @@ -160,7 +161,14 @@ def do_connect(
oracledb.defaults.fetch_decimals = True

def _from_url(self, url: str, **kwargs):
return self.do_connect(user=url.username, password=url.password, dsn=url.host)
url = urlparse(url)
self.do_connect(
user=url.username,
password=url.password,
database=url.path.removeprefix("/"),
)

return self

@property
def current_database(self) -> str:
Expand Down
6 changes: 6 additions & 0 deletions ibis/backends/oracle/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,9 @@ def test_list_tables_schema_warning_refactor(con):
assert con.list_tables(schema="SYS", like="EXU8OPT") == ["EXU8OPT"]

assert con.list_tables(database="SYS", like="EXU8OPT") == ["EXU8OPT"]


def test_from_url(con):
new_con = ibis.connect("oracle://ibis:ibis@localhost:1521/IBIS_TESTING")

assert new_con.list_tables()