Skip to content

Commit

Permalink
fix(oracle): support connection using oracle connection string (ibis-…
Browse files Browse the repository at this point in the history
  • Loading branch information
gforsyth authored Jun 24, 2024
1 parent 2c9198d commit f3cd8b2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
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()

0 comments on commit f3cd8b2

Please sign in to comment.