1313BigIntegerType = BigIntegerType .with_variant (mysql .BIGINT (), 'mysql' )
1414
1515
16-
17-
18-
1916def is_hex (s ):
2017 try :
2118 int (s , base = 16 )
@@ -777,7 +774,8 @@ class Annotations(Base):
777774 AnnotatorID = Column ('annotatorid' , ForeignKey (People .PersonID ))
778775 CitationID = Column ('citationid' , ForeignKey (Citations .CitationID ))
779776
780- PersonObj = relationship (People )
777+ # PersonObj = relationship(People)
778+ AnnotatorObj = relationship (People )
781779 CitationObj = relationship (Citations )
782780
783781
@@ -889,7 +887,6 @@ class ReferenceMaterials(Base):
889887
890888class CalibrationStandards (Base ):
891889
892-
893890 BridgeID = Column ('bridgeid' , Integer , primary_key = True , nullable = False )
894891 ActionID = Column ('actionid' , Integer , ForeignKey (Actions .ActionID ), nullable = False )
895892 ReferenceMaterialID = Column ('referencematerialid' , Integer , ForeignKey (ReferenceMaterials .ReferenceMaterialID ),
@@ -898,18 +895,9 @@ class CalibrationStandards(Base):
898895 ActionObj = relationship (Actions )
899896 ReferenceMaterialObj = relationship (ReferenceMaterials )
900897
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-
909898
910899class ReferenceMaterialValues (Base ):
911900
912-
913901 ReferenceMaterialValueID = Column ('referencematerialvalueid' , Integer , primary_key = True , nullable = False )
914902 ReferenceMaterialID = Column ('referencematerialid' , ForeignKey (ReferenceMaterials .ReferenceMaterialID ),
915903 nullable = False )
@@ -923,12 +911,10 @@ class ReferenceMaterialValues(Base):
923911 ReferenceMaterialObj = relationship (ReferenceMaterials )
924912 UnitObj = relationship (Units )
925913 VariableObj = relationship (Variables )
926- #ResultsObj = relationship(Results, secondary=ResultNormalizationValues)
927914
928915
929916class ResultNormalizationValues (Base ):
930917
931-
932918 ResultID = Column (u'resultid' , ForeignKey (Results .ResultID ), primary_key = True )
933919 ReferenceMaterialValueID = Column (u'referencematerialvalueid' ,
934920 ForeignKey (ReferenceMaterialValues .ReferenceMaterialValueID ),
@@ -940,7 +926,6 @@ class ResultNormalizationValues(Base):
940926
941927class ResultsDataQuality (Base ):
942928
943-
944929 BridgeID = Column ('bridgeid' , Integer , primary_key = True , nullable = False )
945930 ResultID = Column ('resultid' , ForeignKey (Results .ResultID ), nullable = False )
946931 DataQualityID = Column ('dataqualityid' , ForeignKey (DataQuality .DataQualityID ), nullable = False )
@@ -954,7 +939,6 @@ class ResultsDataQuality(Base):
954939# ################################################################################
955940class ExtensionProperties (Base ):
956941
957-
958942 PropertyID = Column ('propertyid' , Integer , primary_key = True , nullable = False )
959943 PropertyName = Column ('propertyname' , String (255 ), nullable = False )
960944 PropertyDescription = Column ('propertydescription' , String (500 ))
@@ -978,7 +962,6 @@ class ActionExtensionPropertyValues(Base):
978962
979963class CitationExtensionPropertyValues (Base ):
980964
981-
982965 BridgeID = Column ('bridgeid' , Integer , primary_key = True , nullable = False )
983966 CitationID = Column ('citationid' , ForeignKey (Citations .CitationID ), nullable = False )
984967 PropertyID = Column ('propertyid' , ForeignKey (ExtensionProperties .PropertyID ), nullable = False )
@@ -1226,6 +1209,7 @@ class MethodCitations(Base):
12261209 RelationshipTypeCV = Column ('relationshiptypecv' , ForeignKey (CVRelationshipType .Name ), nullable = False ,
12271210 index = True )
12281211 CitationID = Column ('citationid' , ForeignKey (Citations .CitationID ), nullable = False )
1212+
12291213 CitationObj = relationship (Citations )
12301214 MethodObj = relationship (Methods )
12311215
@@ -1292,7 +1276,6 @@ class RelatedResults(Base):
12921276# ################################################################################
12931277class PointCoverageResults (Results ):
12941278
1295-
12961279 ResultID = Column ('resultid' , ForeignKey (Results .ResultID ), primary_key = True )
12971280 ZLocation = Column ('zlocation' , Float (53 ))
12981281 ZLocationUnitsID = Column ('zlocationunitsid' , ForeignKey (Units .UnitsID ))
@@ -1310,12 +1293,11 @@ class PointCoverageResults(Results):
13101293 IntendedYSpacingUnitsObj = relationship (Units , primaryjoin = 'PointCoverageResults.IntendedYSpacingUnitsID == Units.UnitsID' )
13111294 SpatialReferenceObj = relationship (SpatialReferences )
13121295 ZLocationUnitsObj = relationship (Units , primaryjoin = 'PointCoverageResults.ZLocationUnitsID == Units.UnitsID' )
1313- # ResultObj = relationship(Results, primaryjoin='PointCoverageResults.ResultID == Results.ResultID')
1314- __mapper_args__ = {'polymorphic_identity' :'Point coverage' }
13151296
1297+ __mapper_args__ = {'polymorphic_identity' : 'Point coverage' }
13161298
1317- class ProfileResults (Results ):
13181299
1300+ class ProfileResults (Results ):
13191301
13201302 ResultID = Column ('resultid' , ForeignKey (Results .ResultID ), primary_key = True )
13211303 XLocation = Column ('xlocation' , Float (53 ))
@@ -1335,12 +1317,11 @@ class ProfileResults(Results):
13351317 SpatialReferenceObj = relationship (SpatialReferences )
13361318 XLocationUnitsObj = relationship (Units , primaryjoin = 'ProfileResults.XLocationUnitsID == Units.UnitsID' )
13371319 YLocationUnitsObj = relationship (Units , primaryjoin = 'ProfileResults.YLocationUnitsID == Units.UnitsID' )
1338- # ResultObj = relationship(Results, primaryjoin='ProfileResults.ResultID == Results.ResultID')
1339- __mapper_args__ = {'polymorphic_identity' :'Profile Coverage' }
13401320
1321+ __mapper_args__ = {'polymorphic_identity' : 'Profile Coverage' }
13411322
1342- class CategoricalResults (Results ):
13431323
1324+ class CategoricalResults (Results ):
13441325
13451326 ResultID = Column ('resultid' , ForeignKey (Results .ResultID ), primary_key = True )
13461327 XLocation = Column ('xlocation' , Float (53 ))
@@ -1357,8 +1338,7 @@ class CategoricalResults(Results):
13571338 YLocationUnitsObj = relationship (Units , primaryjoin = 'CategoricalResults.YLocationUnitsID == Units.UnitsID' )
13581339 ZLocationUnitsObj = relationship (Units , primaryjoin = 'CategoricalResults.ZLocationUnitsID == Units.UnitsID' )
13591340
1360- # ResultObj = relationship(Results, primaryjoin='CategoricalResults.ResultID == Results.ResultID')
1361- __mapper_args__ = {'polymorphic_identity' :'Category coverage' }
1341+ __mapper_args__ = {'polymorphic_identity' :' Category coverage' }
13621342
13631343
13641344class TransectResults (Results ):
@@ -1379,12 +1359,11 @@ class TransectResults(Results):
13791359 IntendedTransectSpacingUnitsObj = relationship (Units , primaryjoin = 'TransectResults.IntendedTransectSpacingUnitsID == Units.UnitsID' )
13801360 SpatialReferenceObj = relationship (SpatialReferences )
13811361 ZLocationUnitsObj = relationship (Units , primaryjoin = 'TransectResults.ZLocationUnitsID == Units.UnitsID' )
1382- # ResultObj = relationship(Results, primaryjoin='TransectResults.ResultID == Results.ResultID')
1383- __mapper_args__ = {'polymorphic_identity' :'Transect Coverage' }
13841362
1363+ __mapper_args__ = {'polymorphic_identity' : 'Transect Coverage' }
13851364
1386- class SpectraResults (Results ):
13871365
1366+ class SpectraResults (Results ):
13881367
13891368 ResultID = Column ('resultid' , ForeignKey (Results .ResultID ), primary_key = True )
13901369 XLocation = Column ('xlocation' , Float (53 ))
@@ -1404,7 +1383,7 @@ class SpectraResults(Results):
14041383 XLocationUnitsObj = relationship (Units , primaryjoin = 'SpectraResults.XLocationUnitsID == Units.UnitsID' )
14051384 YLocationUnitsObj = relationship (Units , primaryjoin = 'SpectraResults.YLocationUnitsID == Units.UnitsID' )
14061385 ZLocationUnitsObj = relationship (Units , primaryjoin = 'SpectraResults.ZLocationUnitsID == Units.UnitsID' )
1407- # ResultObj = relationship(Results, primaryjoin='SpectraResults.ResultID == Results.ResultID')
1386+
14081387 __mapper_args__ = {'polymorphic_identity' :'Spectra coverage' }
14091388
14101389
@@ -1423,14 +1402,13 @@ class TimeSeriesResults(Results):
14231402 AggregationStatisticCV = Column ('aggregationstatisticcv' , ForeignKey (CVAggregationStatistic .Name ),
14241403 nullable = False , index = True )
14251404
1426- # ResultObj = relationship(Results)
14271405 IntendedTimeSpacingUnitsObj = relationship (Units ,
1428- primaryjoin = 'TimeSeriesResults.IntendedTimeSpacingUnitsID == Units.UnitsID' )
1406+ primaryjoin = 'TimeSeriesResults.IntendedTimeSpacingUnitsID == Units.UnitsID' )
14291407 SpatialReferenceObj = relationship (SpatialReferences )
14301408 XLocationUnitsObj = relationship (Units , primaryjoin = 'TimeSeriesResults.XLocationUnitsID == Units.UnitsID' )
14311409 YLocationUnitsObj = relationship (Units , primaryjoin = 'TimeSeriesResults.YLocationUnitsID == Units.UnitsID' )
14321410 ZLocationUnitsObj = relationship (Units , primaryjoin = 'TimeSeriesResults.ZLocationUnitsID == Units.UnitsID' )
1433- # ResultObj = relationship(Results, primaryjoin='TimeSeriesResults.ResultID == Results.ResultID')
1411+
14341412 __mapper_args__ = {'polymorphic_identity' :'Time series coverage' }
14351413
14361414
@@ -1454,13 +1432,12 @@ class SectionResults(Results):
14541432 IntendedZSpacingUnitsObj = relationship (Units , primaryjoin = 'SectionResults.IntendedZSpacingUnitsID == Units.UnitsID' )
14551433 SpatialReferenceObj = relationship (SpatialReferences )
14561434 YLocationUnitsObj = relationship (Units , primaryjoin = 'SectionResults.YLocationUnitsID == Units.UnitsID' )
1457- # ResultObj = relationship(Results, primaryjoin='SectionResults.ResultID == Results.ResultID')
1435+
14581436 __mapper_args__ = {'polymorphic_identity' :'Section coverage' }
14591437
14601438
14611439class TrajectoryResults (Results ):
14621440
1463-
14641441 ResultID = Column ('resultid' , ForeignKey (Results .ResultID ), primary_key = True )
14651442 SpatialReferenceID = Column ('spatialreferenceid' , ForeignKey (SpatialReferences .SpatialReferenceID ))
14661443 IntendedTrajectorySpacing = Column ('intendedtrajectoryspacing' , Float (53 ))
@@ -1474,13 +1451,12 @@ class TrajectoryResults(Results):
14741451 IntendedTrajectorySpacingUnitsObj = relationship (Units ,
14751452 primaryjoin = 'TrajectoryResults.IntendedTrajectorySpacingUnitsID == Units.UnitsID' )
14761453 SpatialReferenceObj = relationship (SpatialReferences )
1477- # ResultObj = relationship(Results, primaryjoin='TrajectoryResults.ResultID == Results.ResultID')
1454+
14781455 __mapper_args__ = {'polymorphic_identity' :'Trajectory coverage' }
14791456
14801457
14811458class MeasurementResults (Results ):
14821459
1483-
14841460 ResultID = Column ('resultid' , ForeignKey (Results .ResultID ), primary_key = True )
14851461 XLocation = Column ('xlocation' , Float (53 ))
14861462 XLocationUnitsID = Column ('xlocationunitsid' , ForeignKey (Units .UnitsID ))
@@ -1502,7 +1478,7 @@ class MeasurementResults(Results):
15021478 XLocationUnitsObj = relationship (Units , primaryjoin = 'MeasurementResults.XLocationUnitsID == Units.UnitsID' )
15031479 YLocationUnitsObj = relationship (Units , primaryjoin = 'MeasurementResults.YLocationUnitsID == Units.UnitsID' )
15041480 ZLocationUnitsObj = relationship (Units , primaryjoin = 'MeasurementResults.ZLocationUnitsID == Units.UnitsID' )
1505- # ResultObj = relationship(Results, primaryjoin='MeasurementResults.ResultID == Results.ResultID')
1481+
15061482 __mapper_args__ = {'polymorphic_identity' :'Measurement' }
15071483
15081484
@@ -1531,7 +1507,6 @@ class MeasurementResultValues(Base):
15311507
15321508class PointCoverageResultValues (Base ):
15331509
1534-
15351510 ValueID = Column ('valueid' , BigIntegerType , primary_key = True )
15361511 ResultID = Column ('resultid' , ForeignKey (PointCoverageResults .ResultID ), nullable = False )
15371512 DataValue = Column ('datavalue' , BigInteger , nullable = False )
@@ -1648,7 +1623,6 @@ def list_repr(self):
16481623
16491624class TrajectoryResultValues (Base ):
16501625
1651-
16521626 ValueID = Column ('valueid' , BigIntegerType , primary_key = True )
16531627 ResultID = Column ('resultid' , ForeignKey (TrajectoryResults .ResultID ), nullable = False )
16541628 DataValue = Column ('datavalue' , Float (53 ), nullable = False )
@@ -1679,7 +1653,6 @@ class TrajectoryResultValues(Base):
16791653
16801654class TransectResultValues (Base ):
16811655
1682-
16831656 ValueID = Column ('valueid' , BigIntegerType , primary_key = True )
16841657 ResultID = Column ('resultid' , ForeignKey (TransectResults .ResultID ), nullable = False )
16851658 DataValue = Column ('datavalue' , Float (53 ), nullable = False )
@@ -1709,7 +1682,6 @@ class TransectResultValues(Base):
17091682
17101683class CategoricalResultValueAnnotations (Base ):
17111684
1712-
17131685 BridgeID = Column ('bridgeid' , Integer , primary_key = True , nullable = False )
17141686 ValueID = Column ('valueid' , BigInteger , ForeignKey (CategoricalResultValues .ValueID ), nullable = False )
17151687 AnnotationID = Column ('annotationid' , ForeignKey (Annotations .AnnotationID ), nullable = False )
@@ -1720,7 +1692,6 @@ class CategoricalResultValueAnnotations(Base):
17201692
17211693class MeasurementResultValueAnnotations (Base ):
17221694
1723-
17241695 BridgeID = Column ('bridgeid' , Integer , primary_key = True , nullable = False )
17251696 ValueID = Column ('valueid' , BigInteger , ForeignKey (MeasurementResultValues .ValueID ), nullable = False )
17261697 AnnotationID = Column ('annotationid' , ForeignKey (Annotations .AnnotationID ), nullable = False )
@@ -1731,7 +1702,6 @@ class MeasurementResultValueAnnotations(Base):
17311702
17321703class PointCoverageResultValueAnnotations (Base ):
17331704
1734-
17351705 BridgeID = Column ('bridgeid' , Integer , primary_key = True , nullable = False )
17361706 ValueID = Column ('valueid' , BigInteger , ForeignKey (PointCoverageResultValues .ValueID ), nullable = False )
17371707 AnnotationID = Column ('annotationid' , ForeignKey (Annotations .AnnotationID ), nullable = False )
@@ -1752,7 +1722,6 @@ class ProfileResultValueAnnotations(Base):
17521722
17531723class SectionResultValueAnnotations (Base ):
17541724
1755-
17561725 BridgeID = Column ('bridgeid' , Integer , primary_key = True , nullable = False )
17571726 ValueID = Column ('valueid' , BigInteger , ForeignKey (SectionResultValues .ValueID ), nullable = False )
17581727 AnnotationID = Column ('annotationid' , ForeignKey (Annotations .AnnotationID ), nullable = False )
@@ -1763,7 +1732,6 @@ class SectionResultValueAnnotations(Base):
17631732
17641733class SpectraResultValueAnnotations (Base ):
17651734
1766-
17671735 BridgeID = Column ('bridgeid' , Integer , primary_key = True , nullable = False )
17681736 ValueID = Column ('valueid' , BigInteger , ForeignKey (SpectraResultValues .ValueID ), nullable = False )
17691737 AnnotationID = Column ('annotationid' , ForeignKey (Annotations .AnnotationID ), nullable = False )
@@ -1774,7 +1742,6 @@ class SpectraResultValueAnnotations(Base):
17741742
17751743class TimeSeriesResultValueAnnotations (Base ):
17761744
1777-
17781745 BridgeID = Column ('bridgeid' , Integer , primary_key = True , nullable = False )
17791746 ValueID = Column ('valueid' , BigInteger , ForeignKey (TimeSeriesResultValues .ValueID ), nullable = False )
17801747 AnnotationID = Column ('annotationid' , ForeignKey (Annotations .AnnotationID ), nullable = False )
@@ -1806,28 +1773,19 @@ class TransectResultValueAnnotations(Base):
18061773def _changeSchema (schema ):
18071774 import inspect
18081775 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
18101777 clsmembers = inspect .getmembers (sys .modules [__name__ ],
18111778 lambda member : inspect .isclass (member ) and member .__module__ == __name__ )
18121779
18131780 for name , Tbl in clsmembers :
18141781 import sqlalchemy .ext .declarative .api as api
18151782
18161783 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 :
18191786 return
18201787 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
18311789
18321790
18331791def _getSchema (engine ):
@@ -1844,8 +1802,6 @@ def _getSchema(engine):
18441802def setSchema (engine ):
18451803
18461804 s = _getSchema (engine )
1847- # if s is None:
1848- # s = ''
18491805 _changeSchema (s )
18501806
18511807
0 commit comments