Skip to content

Commit 948d8cc

Browse files
committed
Completed this phase of updates to sphinx docs
1 parent 8d70f50 commit 948d8cc

File tree

5 files changed

+59
-42
lines changed

5 files changed

+59
-42
lines changed

docs/source/contribute.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ The latest development version is found in the ``development`` branch of the git
4242
pip install git+https://github.com/ODM2/ODM2PythonAPI.git@development#egg=odm2api
4343
4444
45-
Contribute to Documentation
45+
Contribute to documentation
4646
----------------------------------
4747

4848
This guide is a reference on how to contribute to ODM2 Documentation effort

docs/source/getstarted.rst

Lines changed: 55 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ Get Started
22
============
33

44

5-
Install the latest release from a conda package
6-
------------------------------------------------
5+
Install the latest release with conda
6+
-------------------------------------
77

88
conda
9-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
9+
^^^^^
1010

1111
The easiest and most reliable way to install the ODM2 Python API
1212
(``odm2api``) is using the `Conda package management
@@ -29,10 +29,10 @@ changes have been made to support Python 3.x, but they haven't been
2929
tested thoroughly.
3030

3131
Install the conda package
32-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
32+
^^^^^^^^^^^^^^^^^^^^^^^^^
3333

3434
The `latest release <https://github.com/ODM2/ODM2PythonAPI/releases>`_ is available
35-
on the `conda-forge anaconda.org channel <https://anaconda.org/conda-forge/odm2api>`_
35+
as a package on the `conda-forge anaconda.org channel <https://anaconda.org/conda-forge/odm2api>`_
3636
for all major OS platforms (linux, OS X, win32/win64). To install it on
3737
an existing conda environment:
3838

@@ -51,17 +51,63 @@ To create a new environment "myenv" with the ``odm2api`` package:
5151

5252

5353
Code examples
54-
----------------------------------------------
54+
-------------
5555

56+
Connecting to an ODM2 database
57+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5658

59+
Connect to an ODM2 database and open the connection for reading.
60+
61+
.. code-block:: python
62+
63+
from odm2api.ODMconnection import dbconnection
64+
import odm2api.services.readService as odm2rs
65+
66+
# A SQLite file-based connection
67+
session_factory = dbconnection.createConnection('sqlite',
68+
'/myfilepath/odm2db.sqlite')
69+
read = odm2rs.ReadODM2(session_factory)
70+
71+
# A connection to a server-based database system
72+
db_credentials = {
73+
'address': 'ip-or-domainname',
74+
'db': 'dbname',
75+
'user': 'dbuser',
76+
'password': 'password'
77+
}
78+
session_factory = dbconnection.createConnection('postgresql',
79+
**db_credentials)
80+
read = odm2rs.ReadODM2(session_factory)
81+
82+
83+
Updating an entity (table)
84+
^^^^^^^^^^^^^^^^^^^^^^^^^^
85+
86+
The `update services <https://github.com/ODM2/ODM2PythonAPI/blob/master/odm2api/services/updateService.py>`_
87+
have not been fleshed out at this time, for the most part. However, updates can be easily
88+
accomplished by reusing the connection setup at the start of an odm2api session,
89+
then constructing and issuing a direct ``SQL UPDATE`` statement, like this:
90+
91+
.. code-block:: python
92+
93+
from odm2api.ODMconnection import dbconnection
94+
95+
session_factory = dbconnection.createConnection('postgresql',
96+
**db_cred)
97+
DBSession = session_factory.getSession()
98+
99+
sq_str = " UPDATE mytable SET variablecode = 'xyz' WHERE variablecode = 'abc' "
100+
DBSession.execute(sql_str)
101+
DBSession.commit()
57102
58103
59104
Sample Jupyter notebooks
60-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
105+
------------------------
61106

62-
Also mention the associated SQLite ODM2 databases. And the conda environment file.
107+
These two notebooks are complete, extended examples that illustrate reading from ODM2 databases and using the resulting data and metadata. They use SQLite ODM2 file databases that can be `downloaded here <https://github.com/ODM2/ODM2PythonAPI/tree/master/Examples/data>`_.
108+
A conda environment to run these notebooks can be created with the conda environment file
109+
`clientenvironment.yml <https://github.com/ODM2/ODM2PythonAPI/blob/master/Examples/clientenvironment.yml>`_.
63110

64111
1. `WaterQualityMeasurements_RetrieveVisualize.ipynb <https://github.com/ODM2/ODM2PythonAPI/blob/master/Examples/WaterQualityMeasurements_RetrieveVisualize.ipynb>`_
65112

66113
2. `TimeSeries_RetrieveVisualize.ipynb <https://github.com/ODM2/ODM2PythonAPI/blob/master/Examples/TimeSeries_RetrieveVisualize.ipynb>`_
67-

docs/source/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ A Python-based application programmer's interface for the `Observations Data Mod
1313
contribute
1414
credits
1515

16-
Indices
17-
=======
16+
Indices and Search
17+
==================
1818

1919
.. toctree::
2020
:maxdepth: 2

docs/source/models.rst

Lines changed: 0 additions & 29 deletions
This file was deleted.

docs/source/odm2models.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ODM2 is organized with a "core" schema and multiple "extension" schemas that
55
extend the functionality of the core. The following sections cover some overarching concepts
66
for ODM2 and then focus on specific entities within the ODM2 Core schema and ODM2's extension schemas.
77

8-
ODM2Core Entities
8+
ODM2Core entities
99
------------------
1010

1111
The following are entities in the `ODM2 Core Schema <http://odm2.github.io/ODM2/schemas/ODM2_Current/diagrams/ODM2Core.html>`__:

0 commit comments

Comments
 (0)