13
13
BigIntegerType = BigIntegerType .with_variant (mysql .BIGINT (), 'mysql' )
14
14
15
15
16
-
17
-
18
-
19
16
def is_hex (s ):
20
17
try :
21
18
int (s , base = 16 )
@@ -777,7 +774,8 @@ class Annotations(Base):
777
774
AnnotatorID = Column ('annotatorid' , ForeignKey (People .PersonID ))
778
775
CitationID = Column ('citationid' , ForeignKey (Citations .CitationID ))
779
776
780
- PersonObj = relationship (People )
777
+ # PersonObj = relationship(People)
778
+ AnnotatorObj = relationship (People )
781
779
CitationObj = relationship (Citations )
782
780
783
781
@@ -889,7 +887,6 @@ class ReferenceMaterials(Base):
889
887
890
888
class CalibrationStandards (Base ):
891
889
892
-
893
890
BridgeID = Column ('bridgeid' , Integer , primary_key = True , nullable = False )
894
891
ActionID = Column ('actionid' , Integer , ForeignKey (Actions .ActionID ), nullable = False )
895
892
ReferenceMaterialID = Column ('referencematerialid' , Integer , ForeignKey (ReferenceMaterials .ReferenceMaterialID ),
@@ -898,18 +895,9 @@ class CalibrationStandards(Base):
898
895
ActionObj = relationship (Actions )
899
896
ReferenceMaterialObj = relationship (ReferenceMaterials )
900
897
901
- # ResultNormalizationValues = Table(
902
- # u'resultnormalizationvalues', Base.metadata,
903
- # Column(u'resultid', ForeignKey(Results.ResultID), primary_key=True),
904
- # Column(u'normalizedbyreferencematerialvalueid', ForeignKey('odm2.referencematerialvalues.referencematerialvalueid'),
905
- # nullable=False),
906
- # schema='odm2'
907
- # )
908
-
909
898
910
899
class ReferenceMaterialValues (Base ):
911
900
912
-
913
901
ReferenceMaterialValueID = Column ('referencematerialvalueid' , Integer , primary_key = True , nullable = False )
914
902
ReferenceMaterialID = Column ('referencematerialid' , ForeignKey (ReferenceMaterials .ReferenceMaterialID ),
915
903
nullable = False )
@@ -923,12 +911,10 @@ class ReferenceMaterialValues(Base):
923
911
ReferenceMaterialObj = relationship (ReferenceMaterials )
924
912
UnitObj = relationship (Units )
925
913
VariableObj = relationship (Variables )
926
- #ResultsObj = relationship(Results, secondary=ResultNormalizationValues)
927
914
928
915
929
916
class ResultNormalizationValues (Base ):
930
917
931
-
932
918
ResultID = Column (u'resultid' , ForeignKey (Results .ResultID ), primary_key = True )
933
919
ReferenceMaterialValueID = Column (u'referencematerialvalueid' ,
934
920
ForeignKey (ReferenceMaterialValues .ReferenceMaterialValueID ),
@@ -940,7 +926,6 @@ class ResultNormalizationValues(Base):
940
926
941
927
class ResultsDataQuality (Base ):
942
928
943
-
944
929
BridgeID = Column ('bridgeid' , Integer , primary_key = True , nullable = False )
945
930
ResultID = Column ('resultid' , ForeignKey (Results .ResultID ), nullable = False )
946
931
DataQualityID = Column ('dataqualityid' , ForeignKey (DataQuality .DataQualityID ), nullable = False )
@@ -954,7 +939,6 @@ class ResultsDataQuality(Base):
954
939
# ################################################################################
955
940
class ExtensionProperties (Base ):
956
941
957
-
958
942
PropertyID = Column ('propertyid' , Integer , primary_key = True , nullable = False )
959
943
PropertyName = Column ('propertyname' , String (255 ), nullable = False )
960
944
PropertyDescription = Column ('propertydescription' , String (500 ))
@@ -978,7 +962,6 @@ class ActionExtensionPropertyValues(Base):
978
962
979
963
class CitationExtensionPropertyValues (Base ):
980
964
981
-
982
965
BridgeID = Column ('bridgeid' , Integer , primary_key = True , nullable = False )
983
966
CitationID = Column ('citationid' , ForeignKey (Citations .CitationID ), nullable = False )
984
967
PropertyID = Column ('propertyid' , ForeignKey (ExtensionProperties .PropertyID ), nullable = False )
@@ -1226,6 +1209,7 @@ class MethodCitations(Base):
1226
1209
RelationshipTypeCV = Column ('relationshiptypecv' , ForeignKey (CVRelationshipType .Name ), nullable = False ,
1227
1210
index = True )
1228
1211
CitationID = Column ('citationid' , ForeignKey (Citations .CitationID ), nullable = False )
1212
+
1229
1213
CitationObj = relationship (Citations )
1230
1214
MethodObj = relationship (Methods )
1231
1215
@@ -1292,7 +1276,6 @@ class RelatedResults(Base):
1292
1276
# ################################################################################
1293
1277
class PointCoverageResults (Results ):
1294
1278
1295
-
1296
1279
ResultID = Column ('resultid' , ForeignKey (Results .ResultID ), primary_key = True )
1297
1280
ZLocation = Column ('zlocation' , Float (53 ))
1298
1281
ZLocationUnitsID = Column ('zlocationunitsid' , ForeignKey (Units .UnitsID ))
@@ -1310,12 +1293,11 @@ class PointCoverageResults(Results):
1310
1293
IntendedYSpacingUnitsObj = relationship (Units , primaryjoin = 'PointCoverageResults.IntendedYSpacingUnitsID == Units.UnitsID' )
1311
1294
SpatialReferenceObj = relationship (SpatialReferences )
1312
1295
ZLocationUnitsObj = relationship (Units , primaryjoin = 'PointCoverageResults.ZLocationUnitsID == Units.UnitsID' )
1313
- # ResultObj = relationship(Results, primaryjoin='PointCoverageResults.ResultID == Results.ResultID')
1314
- __mapper_args__ = {'polymorphic_identity' :'Point coverage' }
1315
1296
1297
+ __mapper_args__ = {'polymorphic_identity' : 'Point coverage' }
1316
1298
1317
- class ProfileResults (Results ):
1318
1299
1300
+ class ProfileResults (Results ):
1319
1301
1320
1302
ResultID = Column ('resultid' , ForeignKey (Results .ResultID ), primary_key = True )
1321
1303
XLocation = Column ('xlocation' , Float (53 ))
@@ -1335,12 +1317,11 @@ class ProfileResults(Results):
1335
1317
SpatialReferenceObj = relationship (SpatialReferences )
1336
1318
XLocationUnitsObj = relationship (Units , primaryjoin = 'ProfileResults.XLocationUnitsID == Units.UnitsID' )
1337
1319
YLocationUnitsObj = relationship (Units , primaryjoin = 'ProfileResults.YLocationUnitsID == Units.UnitsID' )
1338
- # ResultObj = relationship(Results, primaryjoin='ProfileResults.ResultID == Results.ResultID')
1339
- __mapper_args__ = {'polymorphic_identity' :'Profile Coverage' }
1340
1320
1321
+ __mapper_args__ = {'polymorphic_identity' : 'Profile Coverage' }
1341
1322
1342
- class CategoricalResults (Results ):
1343
1323
1324
+ class CategoricalResults (Results ):
1344
1325
1345
1326
ResultID = Column ('resultid' , ForeignKey (Results .ResultID ), primary_key = True )
1346
1327
XLocation = Column ('xlocation' , Float (53 ))
@@ -1357,8 +1338,7 @@ class CategoricalResults(Results):
1357
1338
YLocationUnitsObj = relationship (Units , primaryjoin = 'CategoricalResults.YLocationUnitsID == Units.UnitsID' )
1358
1339
ZLocationUnitsObj = relationship (Units , primaryjoin = 'CategoricalResults.ZLocationUnitsID == Units.UnitsID' )
1359
1340
1360
- # ResultObj = relationship(Results, primaryjoin='CategoricalResults.ResultID == Results.ResultID')
1361
- __mapper_args__ = {'polymorphic_identity' :'Category coverage' }
1341
+ __mapper_args__ = {'polymorphic_identity' :' Category coverage' }
1362
1342
1363
1343
1364
1344
class TransectResults (Results ):
@@ -1379,12 +1359,11 @@ class TransectResults(Results):
1379
1359
IntendedTransectSpacingUnitsObj = relationship (Units , primaryjoin = 'TransectResults.IntendedTransectSpacingUnitsID == Units.UnitsID' )
1380
1360
SpatialReferenceObj = relationship (SpatialReferences )
1381
1361
ZLocationUnitsObj = relationship (Units , primaryjoin = 'TransectResults.ZLocationUnitsID == Units.UnitsID' )
1382
- # ResultObj = relationship(Results, primaryjoin='TransectResults.ResultID == Results.ResultID')
1383
- __mapper_args__ = {'polymorphic_identity' :'Transect Coverage' }
1384
1362
1363
+ __mapper_args__ = {'polymorphic_identity' : 'Transect Coverage' }
1385
1364
1386
- class SpectraResults (Results ):
1387
1365
1366
+ class SpectraResults (Results ):
1388
1367
1389
1368
ResultID = Column ('resultid' , ForeignKey (Results .ResultID ), primary_key = True )
1390
1369
XLocation = Column ('xlocation' , Float (53 ))
@@ -1404,7 +1383,7 @@ class SpectraResults(Results):
1404
1383
XLocationUnitsObj = relationship (Units , primaryjoin = 'SpectraResults.XLocationUnitsID == Units.UnitsID' )
1405
1384
YLocationUnitsObj = relationship (Units , primaryjoin = 'SpectraResults.YLocationUnitsID == Units.UnitsID' )
1406
1385
ZLocationUnitsObj = relationship (Units , primaryjoin = 'SpectraResults.ZLocationUnitsID == Units.UnitsID' )
1407
- # ResultObj = relationship(Results, primaryjoin='SpectraResults.ResultID == Results.ResultID')
1386
+
1408
1387
__mapper_args__ = {'polymorphic_identity' :'Spectra coverage' }
1409
1388
1410
1389
@@ -1423,14 +1402,13 @@ class TimeSeriesResults(Results):
1423
1402
AggregationStatisticCV = Column ('aggregationstatisticcv' , ForeignKey (CVAggregationStatistic .Name ),
1424
1403
nullable = False , index = True )
1425
1404
1426
- # ResultObj = relationship(Results)
1427
1405
IntendedTimeSpacingUnitsObj = relationship (Units ,
1428
- primaryjoin = 'TimeSeriesResults.IntendedTimeSpacingUnitsID == Units.UnitsID' )
1406
+ primaryjoin = 'TimeSeriesResults.IntendedTimeSpacingUnitsID == Units.UnitsID' )
1429
1407
SpatialReferenceObj = relationship (SpatialReferences )
1430
1408
XLocationUnitsObj = relationship (Units , primaryjoin = 'TimeSeriesResults.XLocationUnitsID == Units.UnitsID' )
1431
1409
YLocationUnitsObj = relationship (Units , primaryjoin = 'TimeSeriesResults.YLocationUnitsID == Units.UnitsID' )
1432
1410
ZLocationUnitsObj = relationship (Units , primaryjoin = 'TimeSeriesResults.ZLocationUnitsID == Units.UnitsID' )
1433
- # ResultObj = relationship(Results, primaryjoin='TimeSeriesResults.ResultID == Results.ResultID')
1411
+
1434
1412
__mapper_args__ = {'polymorphic_identity' :'Time series coverage' }
1435
1413
1436
1414
@@ -1454,13 +1432,12 @@ class SectionResults(Results):
1454
1432
IntendedZSpacingUnitsObj = relationship (Units , primaryjoin = 'SectionResults.IntendedZSpacingUnitsID == Units.UnitsID' )
1455
1433
SpatialReferenceObj = relationship (SpatialReferences )
1456
1434
YLocationUnitsObj = relationship (Units , primaryjoin = 'SectionResults.YLocationUnitsID == Units.UnitsID' )
1457
- # ResultObj = relationship(Results, primaryjoin='SectionResults.ResultID == Results.ResultID')
1435
+
1458
1436
__mapper_args__ = {'polymorphic_identity' :'Section coverage' }
1459
1437
1460
1438
1461
1439
class TrajectoryResults (Results ):
1462
1440
1463
-
1464
1441
ResultID = Column ('resultid' , ForeignKey (Results .ResultID ), primary_key = True )
1465
1442
SpatialReferenceID = Column ('spatialreferenceid' , ForeignKey (SpatialReferences .SpatialReferenceID ))
1466
1443
IntendedTrajectorySpacing = Column ('intendedtrajectoryspacing' , Float (53 ))
@@ -1474,13 +1451,12 @@ class TrajectoryResults(Results):
1474
1451
IntendedTrajectorySpacingUnitsObj = relationship (Units ,
1475
1452
primaryjoin = 'TrajectoryResults.IntendedTrajectorySpacingUnitsID == Units.UnitsID' )
1476
1453
SpatialReferenceObj = relationship (SpatialReferences )
1477
- # ResultObj = relationship(Results, primaryjoin='TrajectoryResults.ResultID == Results.ResultID')
1454
+
1478
1455
__mapper_args__ = {'polymorphic_identity' :'Trajectory coverage' }
1479
1456
1480
1457
1481
1458
class MeasurementResults (Results ):
1482
1459
1483
-
1484
1460
ResultID = Column ('resultid' , ForeignKey (Results .ResultID ), primary_key = True )
1485
1461
XLocation = Column ('xlocation' , Float (53 ))
1486
1462
XLocationUnitsID = Column ('xlocationunitsid' , ForeignKey (Units .UnitsID ))
@@ -1502,7 +1478,7 @@ class MeasurementResults(Results):
1502
1478
XLocationUnitsObj = relationship (Units , primaryjoin = 'MeasurementResults.XLocationUnitsID == Units.UnitsID' )
1503
1479
YLocationUnitsObj = relationship (Units , primaryjoin = 'MeasurementResults.YLocationUnitsID == Units.UnitsID' )
1504
1480
ZLocationUnitsObj = relationship (Units , primaryjoin = 'MeasurementResults.ZLocationUnitsID == Units.UnitsID' )
1505
- # ResultObj = relationship(Results, primaryjoin='MeasurementResults.ResultID == Results.ResultID')
1481
+
1506
1482
__mapper_args__ = {'polymorphic_identity' :'Measurement' }
1507
1483
1508
1484
@@ -1531,7 +1507,6 @@ class MeasurementResultValues(Base):
1531
1507
1532
1508
class PointCoverageResultValues (Base ):
1533
1509
1534
-
1535
1510
ValueID = Column ('valueid' , BigIntegerType , primary_key = True )
1536
1511
ResultID = Column ('resultid' , ForeignKey (PointCoverageResults .ResultID ), nullable = False )
1537
1512
DataValue = Column ('datavalue' , BigInteger , nullable = False )
@@ -1648,7 +1623,6 @@ def list_repr(self):
1648
1623
1649
1624
class TrajectoryResultValues (Base ):
1650
1625
1651
-
1652
1626
ValueID = Column ('valueid' , BigIntegerType , primary_key = True )
1653
1627
ResultID = Column ('resultid' , ForeignKey (TrajectoryResults .ResultID ), nullable = False )
1654
1628
DataValue = Column ('datavalue' , Float (53 ), nullable = False )
@@ -1679,7 +1653,6 @@ class TrajectoryResultValues(Base):
1679
1653
1680
1654
class TransectResultValues (Base ):
1681
1655
1682
-
1683
1656
ValueID = Column ('valueid' , BigIntegerType , primary_key = True )
1684
1657
ResultID = Column ('resultid' , ForeignKey (TransectResults .ResultID ), nullable = False )
1685
1658
DataValue = Column ('datavalue' , Float (53 ), nullable = False )
@@ -1709,7 +1682,6 @@ class TransectResultValues(Base):
1709
1682
1710
1683
class CategoricalResultValueAnnotations (Base ):
1711
1684
1712
-
1713
1685
BridgeID = Column ('bridgeid' , Integer , primary_key = True , nullable = False )
1714
1686
ValueID = Column ('valueid' , BigInteger , ForeignKey (CategoricalResultValues .ValueID ), nullable = False )
1715
1687
AnnotationID = Column ('annotationid' , ForeignKey (Annotations .AnnotationID ), nullable = False )
@@ -1720,7 +1692,6 @@ class CategoricalResultValueAnnotations(Base):
1720
1692
1721
1693
class MeasurementResultValueAnnotations (Base ):
1722
1694
1723
-
1724
1695
BridgeID = Column ('bridgeid' , Integer , primary_key = True , nullable = False )
1725
1696
ValueID = Column ('valueid' , BigInteger , ForeignKey (MeasurementResultValues .ValueID ), nullable = False )
1726
1697
AnnotationID = Column ('annotationid' , ForeignKey (Annotations .AnnotationID ), nullable = False )
@@ -1731,7 +1702,6 @@ class MeasurementResultValueAnnotations(Base):
1731
1702
1732
1703
class PointCoverageResultValueAnnotations (Base ):
1733
1704
1734
-
1735
1705
BridgeID = Column ('bridgeid' , Integer , primary_key = True , nullable = False )
1736
1706
ValueID = Column ('valueid' , BigInteger , ForeignKey (PointCoverageResultValues .ValueID ), nullable = False )
1737
1707
AnnotationID = Column ('annotationid' , ForeignKey (Annotations .AnnotationID ), nullable = False )
@@ -1752,7 +1722,6 @@ class ProfileResultValueAnnotations(Base):
1752
1722
1753
1723
class SectionResultValueAnnotations (Base ):
1754
1724
1755
-
1756
1725
BridgeID = Column ('bridgeid' , Integer , primary_key = True , nullable = False )
1757
1726
ValueID = Column ('valueid' , BigInteger , ForeignKey (SectionResultValues .ValueID ), nullable = False )
1758
1727
AnnotationID = Column ('annotationid' , ForeignKey (Annotations .AnnotationID ), nullable = False )
@@ -1763,7 +1732,6 @@ class SectionResultValueAnnotations(Base):
1763
1732
1764
1733
class SpectraResultValueAnnotations (Base ):
1765
1734
1766
-
1767
1735
BridgeID = Column ('bridgeid' , Integer , primary_key = True , nullable = False )
1768
1736
ValueID = Column ('valueid' , BigInteger , ForeignKey (SpectraResultValues .ValueID ), nullable = False )
1769
1737
AnnotationID = Column ('annotationid' , ForeignKey (Annotations .AnnotationID ), nullable = False )
@@ -1774,7 +1742,6 @@ class SpectraResultValueAnnotations(Base):
1774
1742
1775
1743
class TimeSeriesResultValueAnnotations (Base ):
1776
1744
1777
-
1778
1745
BridgeID = Column ('bridgeid' , Integer , primary_key = True , nullable = False )
1779
1746
ValueID = Column ('valueid' , BigInteger , ForeignKey (TimeSeriesResultValues .ValueID ), nullable = False )
1780
1747
AnnotationID = Column ('annotationid' , ForeignKey (Annotations .AnnotationID ), nullable = False )
@@ -1806,28 +1773,19 @@ class TransectResultValueAnnotations(Base):
1806
1773
def _changeSchema (schema ):
1807
1774
import inspect
1808
1775
import sys
1809
- #get a list of all of the classes in the module
1776
+ # get a list of all of the classes in the module
1810
1777
clsmembers = inspect .getmembers (sys .modules [__name__ ],
1811
1778
lambda member : inspect .isclass (member ) and member .__module__ == __name__ )
1812
1779
1813
1780
for name , Tbl in clsmembers :
1814
1781
import sqlalchemy .ext .declarative .api as api
1815
1782
1816
1783
if isinstance (Tbl , api .DeclarativeMeta ):
1817
- #check to see if the schema is already set correctly
1818
- if Tbl .__table__ .schema == schema :
1784
+ # check to see if the schema is already set correctly
1785
+ if Tbl .__table__ .schema == schema :
1819
1786
return
1820
1787
Tbl .__table__ .schema = schema
1821
- Tbl .__table_args__ ["schema" ]= schema
1822
-
1823
-
1824
- # def _changeSchema(schema):
1825
- # # check to see if the schema is already set correctly
1826
- # # if Base.__table__.schema == schema:
1827
- # # return
1828
- # # Base.__table__.schema = schema
1829
- # Base.__table_args__["schema"] = schema
1830
- # print schema
1788
+ Tbl .__table_args__ ["schema" ]= schema
1831
1789
1832
1790
1833
1791
def _getSchema (engine ):
@@ -1844,8 +1802,6 @@ def _getSchema(engine):
1844
1802
def setSchema (engine ):
1845
1803
1846
1804
s = _getSchema (engine )
1847
- # if s is None:
1848
- # s = ''
1849
1805
_changeSchema (s )
1850
1806
1851
1807
0 commit comments