22
33from odm2api .base import modelBase
44
5- from sqlalchemy import BigInteger , Boolean , Column , Date , DateTime , Float , ForeignKey , Integer , String , case
5+ from sqlalchemy import BigInteger , Boolean , Column , Date , DateTime , Float , ForeignKey , Integer , String , case , types , Table , event
66from sqlalchemy .dialects import mysql , postgresql , sqlite
77from sqlalchemy .orm import relationship
8+ from datetime import datetime , timedelta
89
910Base = modelBase .Base
1011
1314BigIntegerType = BigIntegerType .with_variant (postgresql .BIGINT (), 'postgresql' )
1415BigIntegerType = BigIntegerType .with_variant (mysql .BIGINT (), 'mysql' )
1516
17+ DateTimeType = DateTime ()
18+ DateTimeType = DateTimeType .with_variant (sqlite .INTEGER (), 'sqlite' )
19+
1620
1721def is_hex (s ):
1822 try :
@@ -404,9 +408,9 @@ class Results(Base):
404408 ProcessingLevelID = Column ('processinglevelid' , ForeignKey (ProcessingLevels .ProcessingLevelID ),
405409 nullable = False )
406410 ResultDateTime = Column ('resultdatetime' , DateTime )
407- ResultDateTimeUTCOffset = Column ('resultdatetimeutcoffset' , BigInteger )
411+ ResultDateTimeUTCOffset = Column ('resultdatetimeutcoffset' , BigIntegerType )
408412 ValidDateTime = Column ('validdatetime' , DateTime )
409- ValidDateTimeUTCOffset = Column ('validdatetimeutcoffset' , BigInteger )
413+ ValidDateTimeUTCOffset = Column ('validdatetimeutcoffset' , BigIntegerType )
410414 StatusCV = Column ('statuscv' , ForeignKey (CVStatus .Name ), index = True )
411415 SampledMediumCV = Column ('sampledmediumcv' , ForeignKey (CVMediumType .Name ), nullable = False , index = True )
412416 ValueCount = Column ('valuecount' , Integer , nullable = False )
@@ -503,7 +507,7 @@ class InstrumentOutputVariables(Base):
503507class DataLoggerFileColumns (Base ):
504508
505509 DataLoggerFileColumnID = Column ('dataloggerfilecolumnid' , Integer , primary_key = True , nullable = False )
506- ResultID = Column ('resultid' , BigInteger , ForeignKey (Results .ResultID ))
510+ ResultID = Column ('resultid' , BigIntegerType , ForeignKey (Results .ResultID ))
507511 DataLoggerFileID = Column ('dataloggerfileid' , Integer ,
508512 ForeignKey (DataLoggerFiles .DataLoggerFileID ), nullable = False )
509513 InstrumentOutputVariableID = Column ('instrumentoutputvariableid' , Integer ,
@@ -861,7 +865,7 @@ class ActionAnnotations(Base):
861865class EquipmentAnnotations (Base ):
862866
863867 BridgeID = Column ('bridgeid' , Integer , primary_key = True , nullable = False )
864- EquipmentID = Column ('valueid' , BigInteger , ForeignKey (Equipment .EquipmentID ), nullable = False )
868+ EquipmentID = Column ('valueid' , BigIntegerType , ForeignKey (Equipment .EquipmentID ), nullable = False )
865869 AnnotationID = Column ('annotationid' , ForeignKey (Annotations .AnnotationID ), nullable = False )
866870
867871 AnnotationObj = relationship (Annotations )
@@ -1640,7 +1644,7 @@ class CategoricalResultValues(Base):
16401644 ValueID = Column ('valueid' , BigIntegerType , primary_key = True )
16411645 ResultID = Column ('resultid' , ForeignKey (CategoricalResults .ResultID ), nullable = False )
16421646 DataValue = Column ('datavalue' , String (255 ), nullable = False )
1643- ValueDateTime = Column ('valuedatetime' , DateTime , nullable = False )
1647+ ValueDateTime = Column ('valuedatetime' , DateTimeType , nullable = False )
16441648 ValueDateTimeUTCOffset = Column ('valuedatetimeutcoffset' , Integer , nullable = False )
16451649
16461650 ResultObj = relationship (CategoricalResults )
@@ -1651,7 +1655,7 @@ class MeasurementResultValues(Base):
16511655 ValueID = Column ('valueid' , BigIntegerType , primary_key = True )
16521656 ResultID = Column ('resultid' , ForeignKey (MeasurementResults .ResultID ), nullable = False )
16531657 DataValue = Column ('datavalue' , Float (53 ), nullable = False )
1654- ValueDateTime = Column ('valuedatetime' , DateTime , nullable = False )
1658+ ValueDateTime = Column ('valuedatetime' , DateTimeType , nullable = False )
16551659 ValueDateTimeUTCOffset = Column ('valuedatetimeutcoffset' , Integer , nullable = False )
16561660
16571661 ResultObj = relationship (MeasurementResults )
@@ -1661,8 +1665,8 @@ class PointCoverageResultValues(Base):
16611665
16621666 ValueID = Column ('valueid' , BigIntegerType , primary_key = True )
16631667 ResultID = Column ('resultid' , ForeignKey (PointCoverageResults .ResultID ), nullable = False )
1664- DataValue = Column ('datavalue' , BigInteger , nullable = False )
1665- ValueDateTime = Column ('valuedatetime' , DateTime , nullable = False )
1668+ DataValue = Column ('datavalue' , BigIntegerType , nullable = False )
1669+ ValueDateTime = Column ('valuedatetime' , DateTimeType , nullable = False )
16661670 ValueDateTimeUTCOffset = Column ('valuedatetimeutcoffset' , Integer , nullable = False )
16671671 XLocation = Column ('xlocation' , Float (53 ), nullable = False )
16681672 XLocationUnitsID = Column ('xlocationunitsid' , ForeignKey (Units .UnitsID ), nullable = False )
@@ -1687,7 +1691,7 @@ class ProfileResultValues(Base):
16871691 ValueID = Column ('valueid' , BigIntegerType , primary_key = True )
16881692 ResultID = Column ('resultid' , ForeignKey (ProfileResults .ResultID ), nullable = False )
16891693 DataValue = Column ('datavalue' , Float (53 ), nullable = False )
1690- ValueDateTime = Column ('valuedatetime' , DateTime , nullable = False )
1694+ ValueDateTime = Column ('valuedatetime' , DateTimeType , nullable = False )
16911695 ValueDateTimeUTCOffset = Column ('valuedatetimeutcoffset' , Integer , nullable = False )
16921696 ZLocation = Column ('zlocation' , Float (53 ), nullable = False )
16931697 ZAggregationInterval = Column ('zaggregationinterval' , Float (53 ), nullable = False )
@@ -1714,12 +1718,12 @@ class SectionResultValues(Base):
17141718 ValueID = Column ('valueid' , BigIntegerType , primary_key = True )
17151719 ResultID = Column ('resultid' , ForeignKey (SectionResults .ResultID ), nullable = False )
17161720 DataValue = Column ('datavalue' , Float (53 ), nullable = False )
1717- ValueDateTime = Column ('valuedatetime' , BigInteger , nullable = False )
1718- ValueDateTimeUTCOffset = Column ('valuedatetimeutcoffset' , BigInteger , nullable = False )
1721+ ValueDateTime = Column ('valuedatetime' , DateTimeType , nullable = False )
1722+ ValueDateTimeUTCOffset = Column ('valuedatetimeutcoffset' , Integer , nullable = False )
17191723 XLocation = Column ('xlocation' , Float (53 ), nullable = False )
17201724 XAggregationInterval = Column ('xaggregationinterval' , Float (53 ), nullable = False )
17211725 XLocationUnitsID = Column ('xlocationunitsid' , ForeignKey (Units .UnitsID ), nullable = False )
1722- ZLocation = Column ('zlocation' , BigInteger , nullable = False )
1726+ ZLocation = Column ('zlocation' , BigIntegerType , nullable = False )
17231727 ZAggregationInterval = Column ('zaggregationinterval' , Float (53 ), nullable = False )
17241728 ZLocationUnitsID = Column ('zlocationunitsid' , ForeignKey (Units .UnitsID ), nullable = False )
17251729 CensorCodeCV = Column ('censorcodecv' , ForeignKey (CVCensorCode .Name ), nullable = False , index = True )
@@ -1750,7 +1754,7 @@ class SpectraResultValues(Base):
17501754 ValueID = Column ('valueid' , BigIntegerType , primary_key = True )
17511755 ResultID = Column ('resultid' , ForeignKey (SpectraResults .ResultID ), nullable = False )
17521756 DataValue = Column ('datavalue' , Float (53 ), nullable = False )
1753- ValueDateTime = Column ('valuedatetime' , DateTime , nullable = False )
1757+ ValueDateTime = Column ('valuedatetime' , DateTimeType , nullable = False )
17541758 ValueDateTimeUTCOffset = Column ('valuedatetimeutcoffset' , Integer , nullable = False )
17551759 ExcitationWavelength = Column ('excitationwavelength' , Float (53 ), nullable = False )
17561760 EmissionWavelength = Column ('emmistionwavelength' , Float (53 ), nullable = False )
@@ -1779,7 +1783,7 @@ class TimeSeriesResultValues(Base):
17791783 ValueID = Column ('valueid' , BigIntegerType , primary_key = True )
17801784 ResultID = Column ('resultid' , ForeignKey (TimeSeriesResults .ResultID ), nullable = False )
17811785 DataValue = Column ('datavalue' , Float (53 ), nullable = False )
1782- ValueDateTime = Column ('valuedatetime' , DateTime , nullable = False )
1786+ ValueDateTime = Column ('valuedatetime' , DateTimeType , nullable = False )
17831787 ValueDateTimeUTCOffset = Column ('valuedatetimeutcoffset' , Integer , nullable = False )
17841788 CensorCodeCV = Column ('censorcodecv' , ForeignKey (CVCensorCode .Name ), nullable = False , index = True )
17851789 QualityCodeCV = Column ('qualitycodecv' , ForeignKey (CVQualityCode .Name ), nullable = False , index = True )
@@ -1805,7 +1809,7 @@ class TrajectoryResultValues(Base):
18051809 ValueID = Column ('valueid' , BigIntegerType , primary_key = True )
18061810 ResultID = Column ('resultid' , ForeignKey (TrajectoryResults .ResultID ), nullable = False )
18071811 DataValue = Column ('datavalue' , Float (53 ), nullable = False )
1808- ValueDateTime = Column ('valuedatetime' , DateTime , nullable = False )
1812+ ValueDateTime = Column ('valuedatetime' , DateTimeType , nullable = False )
18091813 ValueDateTimeUTCOffset = Column ('valuedatetimeutcoffset' , Integer , nullable = False )
18101814 XLocation = Column ('xlocation' , Float (53 ), nullable = False )
18111815 XLocationUnitsID = Column ('xlocationunitsid' , ForeignKey (Units .UnitsID ), nullable = False )
@@ -1850,8 +1854,8 @@ class TransectResultValues(Base):
18501854 ValueID = Column ('valueid' , BigIntegerType , primary_key = True )
18511855 ResultID = Column ('resultid' , ForeignKey (TransectResults .ResultID ), nullable = False )
18521856 DataValue = Column ('datavalue' , Float (53 ), nullable = False )
1853- ValueDateTime = Column ('valuedatetime' , DateTime , nullable = False )
1854- ValueDateTimeUTCOffset = Column ('valuedatetimeutcoffset' , DateTime , nullable = False )
1857+ ValueDateTime = Column ('valuedatetime' , DateTimeType , nullable = False )
1858+ ValueDateTimeUTCOffset = Column ('valuedatetimeutcoffset' , Integer , nullable = False )
18551859 XLocation = Column ('xlocation' , Float (53 ), nullable = False )
18561860 XLocationUnitsID = Column ('xlocationunitsid' , ForeignKey (Units .UnitsID ), nullable = False )
18571861 YLocation = Column ('ylocation' , Float (53 ), nullable = False )
@@ -1896,7 +1900,7 @@ class TransectResultValues(Base):
18961900class CategoricalResultValueAnnotations (Base ):
18971901
18981902 BridgeID = Column ('bridgeid' , Integer , primary_key = True , nullable = False )
1899- ValueID = Column ('valueid' , BigInteger , ForeignKey (CategoricalResultValues .ValueID ), nullable = False )
1903+ ValueID = Column ('valueid' , BigIntegerType , ForeignKey (CategoricalResultValues .ValueID ), nullable = False )
19001904 AnnotationID = Column ('annotationid' , ForeignKey (Annotations .AnnotationID ), nullable = False )
19011905
19021906 AnnotationObj = relationship (Annotations )
@@ -1906,7 +1910,7 @@ class CategoricalResultValueAnnotations(Base):
19061910class MeasurementResultValueAnnotations (Base ):
19071911
19081912 BridgeID = Column ('bridgeid' , Integer , primary_key = True , nullable = False )
1909- ValueID = Column ('valueid' , BigInteger , ForeignKey (MeasurementResultValues .ValueID ), nullable = False )
1913+ ValueID = Column ('valueid' , BigIntegerType , ForeignKey (MeasurementResultValues .ValueID ), nullable = False )
19101914 AnnotationID = Column ('annotationid' , ForeignKey (Annotations .AnnotationID ), nullable = False )
19111915
19121916 AnnotationObj = relationship (Annotations )
@@ -1916,7 +1920,7 @@ class MeasurementResultValueAnnotations(Base):
19161920class PointCoverageResultValueAnnotations (Base ):
19171921
19181922 BridgeID = Column ('bridgeid' , Integer , primary_key = True , nullable = False )
1919- ValueID = Column ('valueid' , BigInteger , ForeignKey (PointCoverageResultValues .ValueID ), nullable = False )
1923+ ValueID = Column ('valueid' , BigIntegerType , ForeignKey (PointCoverageResultValues .ValueID ), nullable = False )
19201924 AnnotationID = Column ('annotationid' , ForeignKey (Annotations .AnnotationID ), nullable = False )
19211925
19221926 AnnotationObj = relationship (Annotations )
@@ -1926,7 +1930,7 @@ class PointCoverageResultValueAnnotations(Base):
19261930class ProfileResultValueAnnotations (Base ):
19271931
19281932 BridgeID = Column ('bridgeid' , Integer , primary_key = True , nullable = False )
1929- ValueID = Column ('valueid' , BigInteger , ForeignKey (ProfileResultValues .ValueID ), nullable = False )
1933+ ValueID = Column ('valueid' , BigIntegerType , ForeignKey (ProfileResultValues .ValueID ), nullable = False )
19301934 AnnotationID = Column ('annotationid' , ForeignKey (Annotations .AnnotationID ), nullable = False )
19311935
19321936 AnnotationObj = relationship (Annotations )
@@ -1936,7 +1940,7 @@ class ProfileResultValueAnnotations(Base):
19361940class SectionResultValueAnnotations (Base ):
19371941
19381942 BridgeID = Column ('bridgeid' , Integer , primary_key = True , nullable = False )
1939- ValueID = Column ('valueid' , BigInteger , ForeignKey (SectionResultValues .ValueID ), nullable = False )
1943+ ValueID = Column ('valueid' , BigIntegerType , ForeignKey (SectionResultValues .ValueID ), nullable = False )
19401944 AnnotationID = Column ('annotationid' , ForeignKey (Annotations .AnnotationID ), nullable = False )
19411945
19421946 AnnotationObj = relationship (Annotations )
@@ -1946,7 +1950,7 @@ class SectionResultValueAnnotations(Base):
19461950class SpectraResultValueAnnotations (Base ):
19471951
19481952 BridgeID = Column ('bridgeid' , Integer , primary_key = True , nullable = False )
1949- ValueID = Column ('valueid' , BigInteger , ForeignKey (SpectraResultValues .ValueID ), nullable = False )
1953+ ValueID = Column ('valueid' , BigIntegerType , ForeignKey (SpectraResultValues .ValueID ), nullable = False )
19501954 AnnotationID = Column ('annotationid' , ForeignKey (Annotations .AnnotationID ), nullable = False )
19511955
19521956 AnnotationObj = relationship (Annotations )
@@ -1956,7 +1960,7 @@ class SpectraResultValueAnnotations(Base):
19561960class TimeSeriesResultValueAnnotations (Base ):
19571961
19581962 BridgeID = Column ('bridgeid' , Integer , primary_key = True , nullable = False )
1959- ValueID = Column ('valueid' , BigInteger , ForeignKey (TimeSeriesResultValues .ValueID ), nullable = False )
1963+ ValueID = Column ('valueid' , BigIntegerType , ForeignKey (TimeSeriesResultValues .ValueID ), nullable = False )
19601964 AnnotationID = Column ('annotationid' , ForeignKey (Annotations .AnnotationID ), nullable = False )
19611965
19621966 AnnotationObj = relationship (Annotations )
@@ -1966,7 +1970,7 @@ class TimeSeriesResultValueAnnotations(Base):
19661970class TrajectoryResultValueAnnotations (Base ):
19671971
19681972 BridgeID = Column ('bridgeid' , Integer , primary_key = True , nullable = False )
1969- ValueID = Column ('valueid' , BigInteger , ForeignKey (TrajectoryResultValues .ValueID ), nullable = False )
1973+ ValueID = Column ('valueid' , BigIntegerType , ForeignKey (TrajectoryResultValues .ValueID ), nullable = False )
19701974 AnnotationID = Column ('annotationid' , ForeignKey (Annotations .AnnotationID ), nullable = False )
19711975
19721976 AnnotationObj = relationship (Annotations )
@@ -1976,7 +1980,7 @@ class TrajectoryResultValueAnnotations(Base):
19761980class TransectResultValueAnnotations (Base ):
19771981
19781982 BridgeID = Column ('bridgeid' , Integer , primary_key = True , nullable = False )
1979- ValueID = Column ('valueid' , BigInteger , ForeignKey (TransectResultValues .ValueID ), nullable = False )
1983+ ValueID = Column ('valueid' , BigIntegerType , ForeignKey (TransectResultValues .ValueID ), nullable = False )
19801984 AnnotationID = Column ('annotationid' , ForeignKey (Annotations .AnnotationID ), nullable = False )
19811985
19821986 AnnotationObj = relationship (Annotations )
0 commit comments