@@ -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
88conda
9- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
9+ ^^^^^
1010
1111The 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
2929tested thoroughly.
3030
3131Install the conda package
32- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
32+ ^^^^^^^^^^^^^^^^^^^^^^^^^
3333
3434The `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 >`_
3636for all major OS platforms (linux, OS X, win32/win64). To install it on
3737an existing conda environment:
3838
@@ -51,17 +51,63 @@ To create a new environment "myenv" with the ``odm2api`` package:
5151
5252
5353Code 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
641111. `WaterQualityMeasurements_RetrieveVisualize.ipynb <https://github.com/ODM2/ODM2PythonAPI/blob/master/Examples/WaterQualityMeasurements_RetrieveVisualize.ipynb >`_
65112
661132. `TimeSeries_RetrieveVisualize.ipynb <https://github.com/ODM2/ODM2PythonAPI/blob/master/Examples/TimeSeries_RetrieveVisualize.ipynb >`_
67-
0 commit comments