Skip to content

Commit b256363

Browse files
committed
Updated doc pr.
1 parent a577cce commit b256363

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

docs/source/user_guide/loading_data/connect_legacy.rst

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ For example:
6969
Local Storage
7070
=============
7171

72-
To open a dataset from a local source, use ``ADSDataset`` and specify the path of the data file:
72+
To open a dataset from a local source, use ``pandas`` to load the file into a dataframe, convert it to ``ADSDataset`` and specify the path of the data file:
7373

7474
.. code-block:: python3
7575
@@ -128,10 +128,16 @@ You can also use ``cx_Oracle`` within ADS by creating a connection string:
128128
129129
os.environ['TNS_ADMIN'] = creds['tns_admin']
130130
from ads.dataset.dataset import ADSDataset
131-
uri = 'oracle+cx_oracle://' + creds['user'] + ':' + creds['password'] + '@' + creds['sid']
132-
ds = ADSDataset(
133-
df=pd.read_sql(uri, table=table, index_col=index_col)
134-
)
131+
with cx_Oracle.connect(creds['user'], creds['password'], creds['sid']) as ora_conn:
132+
ds = ADSDataset(
133+
df=pd.read_sql('''
134+
SELECT ename, dname, job, empno, hiredate, loc
135+
FROM emp, dept
136+
WHERE emp.deptno = dept.deptno
137+
ORDER BY ename
138+
''', con=ora_conn
139+
)
140+
)
135141
136142
Autonomous Database
137143
===================
@@ -149,19 +155,17 @@ Oracle has two configurations of Autonomous Databases. They are the Autonomous D
149155
Load from ADB
150156
-------------
151157

152-
After you have stored the ADB username, password, and database name (SID) as variables, you can build the URI as your connection source.
153-
154-
.. code-block:: python3
155-
156-
uri = 'oracle+cx_oracle://' + creds['user'] + ':' + creds['password'] + '@' + creds['sid']
157-
158-
You can use ADS to query a table from your database, and then load that table as an ``ADSDatasetWithTarget`` object.
159-
When you open ``ADSDatasetWithTarget``, specify the name of the table you want to pull using the ``table`` variable for a given table. For SQL expressions, use the table parameter also. For example, *(`table="SELECT * FROM sh.times WHERE rownum <= 30"`)*.
158+
You can use ADS to query a table from your database, by loading that database as a pandas dataframe and convert it to an ``ADSDataset`` or ``ADSDatasetWithTarget`` object.
159+
When you call ``pandas``, specify the name of the table you want to pull.
160160

161161
.. code-block:: python3
162162
163163
os.environ['TNS_ADMIN'] = creds['tns_admin']
164-
ds = ADSDatasetWithTarget(df=pd.read_sql(uri, table=table), target='label')
164+
with cx_Oracle.connect(creds['user'], creds['password'], creds['sid']) as ora_conn:
165+
ds = ADSDatasetWithTarget(
166+
df=pd.read_sql_table(table, con=ora_conn),
167+
target='label'
168+
)
165169
166170
Query ADB
167171
---------
@@ -291,7 +295,7 @@ You can open Amazon S3 public or private files in ADS. For private files, you mu
291295
HTTP(S) Sources
292296
===============
293297

294-
To open a dataset from a remote web server source, use ``ADSDatasetWithTarget`` and specify the URL of the data:
298+
To open a dataset from a remote web server source, use ``pandas`` to load the data from URL, convert it to ``ADSDataset`` or ``ADSDatasetWithTarget`` and specify the URL of the data:
295299

296300
.. code-block:: python3
297301

docs/source/user_guide/quickstart/quickstart.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ to use (regression, binary, and multi-class classification, or time series forec
6060

6161
There are several ways to turn data into an ``ADSDataset``. The simplest way is to
6262
use `ADSDataset` or `ADSDatasetWithTarget` constructor, which takes as its first argument
63-
as a ``Pandas Dataframe`` object. The ``Pandas Dataframe`` supports many formats, such as
64-
Object Storage or S3 files. The
63+
as a ``Pandas Dataframe`` object. The ``Pandas Dataframe`` supports loading data from many
64+
URL schemes, such as Object Storage or S3 files. The
6565
`class documentation <https://docs.cloud.oracle.com/en-us/iaas/tools/ads-sdk/latest/modules.html>_` describes all classes.
6666

6767
For example:

0 commit comments

Comments
 (0)