Skip to content

Commit 44e398c

Browse files
authored
docs: update documentation for database-usage (#96)
The PR fixes the following: - links to other documentation - confusing wording - incorrect references to instance instead of database - incorrect grammar
1 parent 16a812f commit 44e398c

File tree

1 file changed

+40
-37
lines changed

1 file changed

+40
-37
lines changed

docs/database-usage.rst

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,39 @@
11
Database Admin
22
==============
33

4-
After creating a :class:`~google.cloud.spanner.instance.Instance`, you can
4+
After creating an :class:`~google.cloud.spanner_v1.instance.Instance`, you can
55
interact with individual databases for that instance.
66

77

88
List Databases
99
--------------
1010

1111
To iterate over all existing databases for an instance, use its
12-
:meth:`~google.cloud.spanner.instance.Instance.list_databases` method:
12+
:meth:`~google.cloud.spanner_v1.instance.Instance.list_databases` method:
1313

1414
.. code:: python
1515
1616
for database in instance.list_databases():
1717
# `database` is a `Database` object.
1818
19-
This method yields :class:`~.spanner_admin_database_v1.types.Database`
19+
This method yields :class:`~google.cloud.spanner_v1.database.Database`
2020
objects.
2121

2222

2323
Database Factory
2424
----------------
2525

26-
To create a :class:`~google.cloud.spanner.database.Database` object:
26+
To create a :class:`~google.cloud.spanner_v1.database.Database` object:
2727

2828
.. code:: python
2929
3030
database = instance.database(database_id, ddl_statements)
3131
32-
- ``ddl_statements`` is a list of strings containing DDL for the new database.
32+
- ``ddl_statements`` is a list of strings containing DDL statements for the new database.
3333

34-
You can also use :meth:`Instance.database` to create a local wrapper for
35-
a database that has already been created:
34+
You can also use the :meth:`~google.cloud.spanner_v1.instance.Instance.database` method
35+
on an :class:`~google.cloud.spanner_v1.instance.Instance` object to create a local wrapper
36+
for a database that has already been created:
3637

3738
.. code:: python
3839
@@ -43,7 +44,7 @@ Create a new Database
4344
---------------------
4445

4546
After creating the database object, use its
46-
:meth:`~google.cloud.spanner.database.Database.create` method to
47+
:meth:`~google.cloud.spanner_v1.database.Database.create` method to
4748
trigger its creation on the server:
4849

4950
.. code:: python
@@ -52,8 +53,8 @@ trigger its creation on the server:
5253
5354
.. note::
5455

55-
Creating an instance triggers a "long-running operation" and
56-
returns an :class:`~concurrent.futures.Future`-like object. Use
56+
Creating a database triggers a "long-running operation" and
57+
returns a :class:`~concurrent.futures.Future`-like object. Use
5758
the :meth:`~concurrent.futures.Future.result` method to wait for
5859
and inspect the result.
5960

@@ -62,21 +63,21 @@ Update an existing Database
6263
---------------------------
6364

6465
After creating the database object, you can apply additional DDL statements
65-
via its :meth:`~google.cloud.spanner.database.Database.update_ddl` method:
66+
via its :meth:`~google.cloud.spanner_v1.database.Database.update_ddl` method:
6667

6768
.. code:: python
6869
6970
operation = database.update_ddl(ddl_statements, operation_id)
7071
71-
- ``ddl_statements`` is a list of strings containing DDL to be applied to
72-
the database.
72+
- ``ddl_statements`` is a list of strings containing DDL statements to be
73+
applied to the database.
7374

7475
- ``operation_id`` is a string ID for the long-running operation.
7576

7677
.. note::
7778

78-
Update an instance triggers a "long-running operation" and
79-
returns a :class:`google.cloud.spanner.database.Operation`
79+
Updating a database triggers a "long-running operation" and
80+
returns an :class:`~google.cloud.spanner_v1.database.Operation`
8081
object. See :ref:`check-on-current-database-operation` for polling
8182
to find out if the operation is completed.
8283

@@ -85,7 +86,7 @@ Drop a Database
8586
---------------
8687

8788
Drop a database using its
88-
:meth:`~google.cloud.spanner.database.Database.drop` method:
89+
:meth:`~google.cloud.spanner_v1.database.Database.drop` method:
8990

9091
.. code:: python
9192
@@ -97,14 +98,15 @@ Drop a database using its
9798
Check on Current Database Operation
9899
-----------------------------------
99100

100-
The :meth:`~google.cloud.spanner.database.Database.create` and
101-
:meth:`~google.cloud.spanner.database.Database.update` methods of instance
102-
object trigger long-running operations on the server, and return instances
101+
The :meth:`~google.cloud.spanner_v1.database.Database.create` and
102+
:meth:`~google.cloud.spanner_v1.database.Database.update_ddl` methods of the
103+
:class:`~google.cloud.spanner_v1.database.Database` object trigger
104+
long-running operations on the server, and return operations
103105
conforming to the :class:`~.concurrent.futures.Future` class.
104106

105107
.. code:: python
106108
107-
>>> operation = instance.create()
109+
>>> operation = database.create()
108110
>>> operation.result()
109111
110112
@@ -116,24 +118,25 @@ Use a Snapshot to Read / Query the Database
116118

117119
A snapshot represents a read-only point-in-time view of the database.
118120

119-
Calling :meth:`~google.cloud.spanner.database.Database.snapshot` with
121+
Calling :meth:`~google.cloud.spanner_v1.database.Database.snapshot` with
120122
no arguments creates a snapshot with strong concurrency:
121123

122124
.. code:: python
123125
124126
with database.snapshot() as snapshot:
125127
do_something_with(snapshot)
126128
127-
See :class:`~google.cloud.spanner.snapshot.Snapshot` for the other options
129+
See :class:`~google.cloud.spanner_v1.snapshot.Snapshot` for the other options
128130
which can be passed.
129131

130132
.. note::
131133

132-
:meth:`~google.cloud.spanner.database.Database.snapshot` returns an
134+
:meth:`~google.cloud.spanner_v1.database.Database.snapshot` returns an
133135
object intended to be used as a Python context manager (i.e., as the
134-
target of a ``with`` statement). Use the instance, and any result
135-
sets returned by its ``read`` or ``execute_sql`` methods, only inside
136-
the block created by the ``with`` statement.
136+
target of a ``with`` statement). Perform all iterations within the
137+
context of the ``with database.snapshot()`` block.
138+
139+
137140

138141
See :doc:`snapshot-usage` for more complete examples of snapshot usage.
139142

@@ -151,7 +154,7 @@ on the rows of tables in the database.
151154
152155
.. note::
153156

154-
:meth:`~google.cloud.spanner.database.Database.batch` returns an
157+
:meth:`~google.cloud.spanner_v1.database.Database.batch` returns an
155158
object intended to be used as a Python context manager (i.e., as the
156159
target of a ``with`` statement). It applies any changes made inside
157160
the block of its ``with`` statement when exiting the block, unless an
@@ -187,26 +190,26 @@ transaction as a required argument:
187190
188191
.. note::
189192

190-
:meth:`~google.cloud.spanner.database.Database.run_in_transaction`
193+
:meth:`~google.cloud.spanner_v1.database.Database.run_in_transaction`
191194
commits the transaction automatically if the "unit of work" function
192195
returns without raising an exception.
193196

194197
.. note::
195198

196-
:meth:`~google.cloud.spanner.database.Database.run_in_transaction`
197-
retries the "unit of work" function if the read / query operatoins
198-
or the commit are aborted due to concurrent updates
199+
:meth:`~google.cloud.spanner_v1.database.Database.run_in_transaction`
200+
retries the "unit of work" function if the read / query operations
201+
or the commit are aborted due to concurrent updates.
199202

200203
See :doc:`transaction-usage` for more complete examples of transaction usage.
201204

202205
Configuring a session pool for a database
203206
-----------------------------------------
204207

205208
Under the covers, the ``snapshot``, ``batch``, and ``run_in_transaction``
206-
methods use a pool of :class:`~google.cloud.spanner.session.Session` objects
209+
methods use a pool of :class:`~google.cloud.spanner_v1.session.Session` objects
207210
to manage their communication with the back-end. You can configure
208211
one of the pools manually to control the number of sessions, timeouts, etc.,
209-
and then passing it to the :class:`~google.cloud.spanner.database.Database`
212+
and then pass it to the :class:`~google.cloud.spanner_v1.database.Database`
210213
constructor:
211214

212215
.. code-block:: python
@@ -221,12 +224,12 @@ constructor:
221224
pool = spanner.FixedSizePool(size=10, default_timeout=5)
222225
database = instance.database(DATABASE_NAME, pool=pool)
223226
224-
Note that creating a database with a pool may presume that its database
225-
already exists, as it may need to pre-create sessions (rather than creating
226-
them on demand, as the default implementation does).
227+
Note that creating a database with a pool will require the database to
228+
already exist if the pool implementation needs to pre-create sessions
229+
(rather than creating them on demand, as the default implementation does).
227230

228231
You can supply your own pool implementation, which must satisfy the
229-
contract laid out in :class:`~google.cloud.spanner.pool.AbstractSessionPool`:
232+
contract laid out in :class:`~google.cloud.spanner_v1.pool.AbstractSessionPool`:
230233

231234
.. code-block:: python
232235

0 commit comments

Comments
 (0)