Skip to content

Commit d24f8f2

Browse files
author
sreeder
committed
fix warning message that shows up in api
1 parent 027f5bd commit d24f8f2

6 files changed

Lines changed: 218 additions & 126 deletions

File tree

src/Examples/Sample.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121

2222
#connect to database
2323
#createconnection (dbtype, servername, dbname, username, password)
24-
session_factory = dbconnection.createConnection('mysql', 'localhost', 'odm2', 'ODM', 'odm')
24+
#session_factory = dbconnection.createConnection('mysql', 'localhost', 'odm2', 'ODM', 'odm')
25+
session_factory = dbconnection.createConnection('mysql', 'jws.uwrl.usu.edu', 'odm2', 'ODM', 'ODM123!!', 2)
2526

2627

2728

@@ -76,6 +77,26 @@
7677
except Exception as e:
7778
print "Unable to demo getSamplingFeatureByCode: ", e
7879

80+
#add sampling feature
81+
try:
82+
from api.ODM2.models import SamplingFeatures
83+
newsf = SamplingFeatures()
84+
newsf = SamplingFeatures()
85+
newsf.FeatureGeometry = sf.FeatureGeometry
86+
newsf.Elevation_m=100
87+
newsf.ElevationDatumCV=sf.ElevationDatumCV
88+
newsf.SamplingFeatureCode= "TestSF"
89+
newsf.SamplingFeatureDescription = "this is a test to add Feature Geomotry"
90+
newsf.SamplingFeatureGeotypeCV= sf.SamplingFeatureGeotypeCV
91+
newsf.SamplingFeatureTypeCV=sf.SamplingFeatureTypeCV
92+
newsf.SamplingFeatureUUID= sf.SamplingFeatureUUID+"1"
93+
session_factory.getSession().add(newsf)
94+
session_factory.getSession().commit()
95+
print "new sampling deature added to database", newsf
96+
97+
except Exception as e :
98+
print "error adding a sampling feature" + e
99+
79100

80101
# Drill down and get objects linked by foreign keys
81102
print "\n------------ Foreign Key Example --------- \n",

src/Examples/Sample1_1.py

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
__author__ = 'stephanie'
2+
3+
import matplotlib.pyplot as plt
4+
from matplotlib import dates
5+
import pprint
6+
from api.ODMconnection import dbconnection
7+
from api.ODM1_1_1.services import SeriesService
8+
9+
10+
# Create a connection to the ODM2 database
11+
# ----------------------------------------
12+
13+
#createconnection (dbtype, servername, dbname, username, password)
14+
#session_factory = dbconnection.createConnection('mysql', 'localhost', 'odm2', 'ODM', 'odm')
15+
session_factory = dbconnection.createConnection('mysql', 'jws.uwrl.usu.edu', 'odm2', 'ODM', 'ODM123!!', 2)
16+
17+
18+
#ODM1 DB
19+
#conn = dbconnection.createConnection('mysql', 'jws.uwrl.usu.edu', 'odm', "ODM", "ODM123!!", 1.1)
20+
21+
pp = pprint.PrettyPrinter(indent=8)
22+
23+
print
24+
print "************************************************"
25+
print "\t\tODM2 -> ODM1 Demo: "
26+
print "************************************************"
27+
print
28+
29+
odm1service = SeriesService(session_factory)
30+
pp.pprint(session_factory)
31+
32+
print
33+
print "************************************************"
34+
print "\t\tUnits: get_all_units()"
35+
print "************************************************"
36+
print
37+
38+
pp.pprint(odm1service.get_all_units())
39+
40+
print
41+
print "************************************************"
42+
print "\t\tSites: get_all_sites()"
43+
print "************************************************"
44+
print
45+
46+
pp.pprint(odm1service.get_all_sites())
47+
48+
print
49+
print "************************************************"
50+
print "\t\tMethods: get_all_methods()"
51+
print "************************************************"
52+
print
53+
54+
pp.pprint(odm1service.get_all_methods())
55+
56+
print
57+
print "************************************************"
58+
print "\t\tVariables: get_all_variables()"
59+
print "************************************************"
60+
print
61+
62+
pp.pprint(odm1service.get_all_variables())
63+
64+
print
65+
print "************************************************"
66+
print "\t\tData Sources: get_all_Source()"
67+
print "************************************************"
68+
print
69+
70+
pp.pprint(odm1service.get_all_sources())
71+
72+
73+
print
74+
print "************************************************"
75+
print "\t\tData Values: get_all_series()"
76+
print "************************************************"
77+
print
78+
79+
pp.pprint(odm1service.get_all_series())
80+
81+
82+
print
83+
print "************************************************"
84+
print "\t\tData Values: get_all_DataValues()"
85+
print "************************************************"
86+
print
87+
88+
pp.pprint(odm1service.get_values_by_series(1))
89+

0 commit comments

Comments
 (0)