Skip to content

Commit e507236

Browse files
author
Stephanie Reeder
committed
add sample for 1.1
1 parent 905514c commit e507236

File tree

1 file changed

+92
-0
lines changed

1 file changed

+92
-0
lines changed

src/Examples/Sample 1.1.py

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
__author__ = 'stephanie'
2+
import sys
3+
import os
4+
from api.ODMconnection import dbconnection
5+
import pprint
6+
from api.ODM1_1_1.services import SeriesService
7+
8+
this_file = os.path.realpath(__file__)
9+
directory = os.path.dirname(this_file)
10+
sys.path.insert(0, directory)
11+
12+
13+
14+
# ----------------------------------------
15+
conns = [
16+
#connection to the ODM1 database
17+
dbconnection.createConnection('mysql', 'jws.uwrl.usu.edu', 'odm', "ODM", "ODM123!!", 1.1),
18+
#connection to the ODM2 database
19+
dbconnection.createConnection('mysql', 'jws.uwrl.usu.edu', 'odm2', 'ODM', 'ODM123!!', 2.0)]
20+
21+
22+
for conn in conns:
23+
pp = pprint.PrettyPrinter(indent=8)
24+
25+
print
26+
print "************************************************"
27+
print "\t\tODM2 -> ODM1 Demo: "
28+
print "************************************************"
29+
print
30+
31+
odm1service = SeriesService(conn)
32+
odm1service.refreshDB(conn.version)
33+
pp.pprint(conn)
34+
35+
print
36+
print "************************************************"
37+
print "\t\tUnits: get_all_units()"
38+
print "************************************************"
39+
print
40+
41+
pp.pprint(odm1service.get_unit_by_id(321))
42+
43+
print
44+
print "************************************************"
45+
print "\t\tSites: get_all_sites()"
46+
print "************************************************"
47+
print
48+
49+
pp.pprint(odm1service.get_all_sites())
50+
51+
print
52+
print "************************************************"
53+
print "\t\tMethods: get_all_methods()"
54+
print "************************************************"
55+
print
56+
57+
pp.pprint(odm1service.get_method_by_id(8))
58+
59+
print
60+
print "************************************************"
61+
print "\t\tVariables: get_all_variables()"
62+
print "************************************************"
63+
print
64+
65+
pp.pprint(odm1service.get_variable_by_id(10))
66+
67+
print
68+
print "************************************************"
69+
print "\t\tData Sources: get_all_Source()"
70+
print "************************************************"
71+
print
72+
73+
pp.pprint(odm1service.get_all_sources())
74+
75+
print
76+
print "************************************************"
77+
print "\t\tData Values: get_all_series()"
78+
print "************************************************"
79+
print
80+
81+
pp.pprint(odm1service.get_series_by_id(1))
82+
83+
print
84+
print "************************************************"
85+
print "\t\tData Values: get_all_DataValues()"
86+
print "************************************************"
87+
print
88+
89+
pp.pprint(odm1service.get_values_by_series(1))
90+
print "The end"
91+
92+

0 commit comments

Comments
 (0)