|
2 | 2 |
|
3 | 3 |
|
4 | 4 |
|
5 | | -import matplotlib.pyplot as plt |
6 | | -from matplotlib import dates |
| 5 | +# import matplotlib.pyplot as plt |
| 6 | + |
7 | 7 |
|
8 | 8 |
|
9 | 9 |
|
|
17 | 17 | #connect to database |
18 | 18 | # createconnection (dbtype, servername, dbname, username, password) |
19 | 19 | # session_factory = dbconnection.createConnection('connection type: sqlite|mysql|mssql|postgresql', '/your/path/to/db/goes/here', 2.0)#sqlite |
20 | | -# session_factory = dbconnection.createConnection('mysql', 'localhost', 'odm2', 'ODM', 'odm')#mysql |
| 20 | +session_factory = dbconnection.createConnection('mysql', 'localhost', 'odm2', 'ODM', 'odm')#mysql |
21 | 21 | # session_factory= dbconnection.createConnection('mssql', "(local)", "LBRODM2", "ODM", "odm")#win MSSQL |
22 | | -session_factory= dbconnection.createConnection('mssql', "arroyoodm2", "", "ODM", "odm")#mac/linux MSSQL |
23 | | -# session_factory = dbconnection.createConnection('sqlite', '/Users/Stephanie/Desktop/TestODM2.db', 2.0) |
| 22 | +# session_factory= dbconnection.createConnection('mssql', "arroyoodm2", "", "ODM", "odm")#mac/linux MSSQL |
| 23 | +# session_factory = dbconnection.createConnection('sqlite', '/Users/stephanie/DEV/ODM2/usecases/WOF_to_ODM2/ODM2.sqlite', 2.0) |
| 24 | + |
24 | 25 |
|
25 | 26 |
|
26 | 27 |
|
|
60 | 61 | siteFeatures = read.getSamplingFeatures() |
61 | 62 | # siteFeatures = read.getSamplingFeatures(type='Site') |
62 | 63 | numSites = len(siteFeatures) |
63 | | - |
| 64 | + print ("Successful query") |
64 | 65 | for x in siteFeatures: |
65 | 66 | print(x.SamplingFeatureCode + ": " + x.SamplingFeatureTypeCV ) |
66 | 67 | except Exception as e: |
|
69 | 70 |
|
70 | 71 | # Now get the SamplingFeature object for a SamplingFeature code |
71 | 72 | try: |
72 | | - sf = read.getSamplingFeatures(code=['USU-LBR-Mendon'])[0] |
| 73 | + sf = read.getSamplingFeatures(codes=['USU-LBR-Mendon'])[0] |
73 | 74 | print(sf) |
74 | 75 | print("\n-------- Information about an individual SamplingFeature ---------") |
75 | 76 | print("The following are some of the attributes of a SamplingFeature retrieved using getSamplingFeatureByCode(): \n") |
|
88 | 89 | # from odm2api.ODM2.models import SamplingFeatures |
89 | 90 | session = session_factory.getSession() |
90 | 91 | newsf = Sites(FeatureGeometryWKT = "POINT(-111.946 41.718)", Elevation_m=100, ElevationDatumCV=sf.ElevationDatumCV, |
91 | | - SamplingFeatureCode= "TestSF",SamplingFeatureDescription = "this is a test to add Feature Geomotry", |
| 92 | + SamplingFeatureCode= "TestSF",SamplingFeatureDescription = "this is a test in sample.py", |
92 | 93 | SamplingFeatureGeotypeCV= "Point", SamplingFeatureTypeCV=sf.SamplingFeatureTypeCV,SamplingFeatureUUID= sf.SamplingFeatureUUID+"2", |
93 | 94 | SiteTypeCV="cave", Latitude= "100", Longitude= "-100", SpatialReferenceID= 0) |
94 | 95 |
|
95 | | - create.createSamplingFeature(newsf) |
| 96 | + c=create.createSamplingFeature(newsf) |
96 | 97 | #session.commit() |
97 | | - print("new sampling feature added to database", newsf) |
| 98 | + print("new sampling feature added to database", c) |
98 | 99 |
|
99 | 100 | except Exception as e : |
100 | 101 | print("error adding a sampling feature: " + str(e)) |
|
0 commit comments