Skip to content

Commit 3d82f7c

Browse files
author
Stephanie Reeder
committed
merge
2 parents fe403bd + 39340e4 commit 3d82f7c

30 files changed

+643
-1192
lines changed

src/Examples/Sample.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,16 @@
1313
print directory
1414
sys.path.insert(0, directory)
1515

16-
from src.api.ODMconnection import dbconnection
17-
from src.api.ODM2.services.readService import *
16+
from api.ODMconnection import dbconnection
17+
from api.ODM2.services.readService import *
1818
# Create a connection to the ODM2 database
1919
# ----------------------------------------
2020

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",
Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
1-
import sys
2-
import os
3-
from src.api.ODMconnection import dbconnection
4-
import pprint
5-
from src.api.ODM1_1_1.services import SeriesService
1+
__author__ = 'stephanie'
62

7-
this_file = os.path.realpath(__file__)
8-
directory = os.path.dirname(this_file)
9-
sys.path.insert(0, directory)
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
108

119

1210
# Create a connection to the ODM2 database
1311
# ----------------------------------------
14-
# conn = dbconnection.createConnection('mysql', 'localhost', 'odm2', 'ODM', 'ODM123!!')
15-
# conn = dbconnection.createConnection('mysql', 'jws.uwrl.usu.edu', 'odm2', 'ODM', 'ODM123!!', 2.0)
16-
# conn = dbconnection.createConnection('mssql', '(local)', 'ODM2SS', 'ODM', 'odm')
17-
# conn = dbconnection.createConnection('postgresql', 'localhost', 'ODM2', 'odm', 'odm')
18-
# conn = dbconnection.createConnection('mysql', '127.0.0.1:3306', 'ODM2', 'Stephanie', 'odm')
19-
# -------------------------------------------------
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+
2017

2118
#ODM1 DB
22-
conn = dbconnection.createConnection('mysql', 'jws.uwrl.usu.edu', 'odm', "ODM", "ODM123!!", 1.1)
19+
# session_factory = dbconnection.createConnection('mysql', 'jws.uwrl.usu.edu', 'odm', "ODM", "ODM123!!", 1.1)
2320

2421
pp = pprint.PrettyPrinter(indent=8)
2522

@@ -29,8 +26,8 @@
2926
print "************************************************"
3027
print
3128

32-
odm1service = SeriesService(conn)
33-
pp.pprint(conn)
29+
odm1service = SeriesService(session_factory)
30+
pp.pprint(session_factory)
3431

3532
print
3633
print "************************************************"
@@ -79,7 +76,7 @@
7976
print "************************************************"
8077
print
8178

82-
#pp.pprint(odm1service.get_all_series())
79+
pp.pprint(odm1service.get_all_series())
8380

8481

8582
print
@@ -88,7 +85,5 @@
8885
print "************************************************"
8986
print
9087

91-
#pp.pprint(odm1service.get_values_by_series(1))
92-
88+
pp.pprint(odm1service.get_values_by_series(1))
9389

94-
#

src/api/Demo.py

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

0 commit comments

Comments
 (0)