class TestModel2(BigQueryModel):

    __tablename__ = 'unittest.test2'

    id = Column(Integer)
    c1 = Column(Integer)
    c2 = Column(Integer, nullable=False, default=2)
class TestModel8(BigQueryModel):

    __tablename__ = 'unittest.test8'

    intr = Column(Integer)
    created_date = Column(sqlalchemy.DateTime,
                          nullable=False,
                          default=datetime.datetime.utcnow)
class TestModel11(BigQueryModel):

    __tablename__ = 'unittest.test11'

    intr = Column(Integer)
    date = Column(sqlalchemy.Date)

    def __eq__(self, other):
        return (isinstance(other, TestModel11) and self.intr == other.intr
                and self.date == other.date)
class TestModel10_2(BigQueryModel):

    __tablename__ = 'unittest.test10_2'

    intr = Column(Integer)
    string = Column(String)

    def __eq__(self, other):
        return (isinstance(other, TestModel10_2) and self.intr == other.intr
                and self.string == other.string)
class Test4Model2(BigQueryModel):

    __tablename__ = 'unittest.test4_2'

    id = Column(Integer)
    c2 = Column(Integer, nullable=True)
    c3 = Column(Integer, nullable=True)

    def __repr__(self):
        return 'Test4Model2(id={})'.format(self.id)
class TestModel3(BigQueryModel):

    __tablename__ = 'test3'

    id = Column(Integer)
    geo = Column(GeographyWKT, nullable=True)
    geo2 = Column(GeographyGeoJson, nullable=True)
    c1 = Column(String(10), nullable=True)
    default_int = Column(Integer, nullable=False, default=1)

    def __repr__(self):
        return 'TestModel3(id={})'.format(self.id)
class TestModel12(BigQueryModel):

    __tablename__ = 'unittest.test12'

    id = Column(Integer)
    column1 = Column(Integer, nullable=False, default=1)

    def __repr__(self):
        return 'TestModel(id={}, column1={})'.format(self.id, self.column1)

    def __eq__(self, other):
        return (self.id == other.id and self.column1 == other.column1)
class TestGeoModel(BigQueryModel):

    __tablename__ = 'unittest.test_geo'

    id = Column(Integer)
    geometry1 = Column(GeographyWKT, nullable=True)
    geometry2 = Column(GeographyGeoJson, nullable=True)

    def __repr__(self):
        return 'TestModel(id={}, geo1={}, geo2={})'.format(
            self.id, self.geometry1, self.geometry2)

    def __eq__(self, other):
        return (self.id == other.id)
class TestModel10_3(BigQueryModel):

    __tablename__ = 'unittest.test10_3'

    intr = Column(Integer)
    double = Column(sqlalchemy.Float)
    string = Column(String)

    def __eq__(self, other):
        return (isinstance(other, TestModel10_3) and self.intr == other.intr
                and self.double == other.double
                and self.string == other.string)

    def __ne__(self, o):
        return not self.__eq__(o)
Exemple #10
0
class TestModelCluster3(BigQueryModel):

    __tablename__ = 'unittest.table_test_cluster3'

    __table_args__ = {
        'info': {
            'bigquery_partition_by': ['partition_column'],
            'bigquery_cluster_by': ['string', 'boolean'],
        }
    }

    intr = Column(Integer)
    boolean = Column(sqlalchemy.Boolean, nullable=False)
    string = Column(String(10))  # Give maximum length
    partition_column = Column(sqlalchemy.TIMESTAMP)
class TestModel9(BigQueryModel):

    __tablename__ = 'unittest.test9'

    intr = Column(Integer)
    double = Column(sqlalchemy.Float)
    created_date = Column(sqlalchemy.DateTime,
                          nullable=False,
                          default=datetime.datetime.utcnow)
    geojson = Column(GeographyGeoJson, nullable=True)

    def __eq__(self, other):
        return (isinstance(other, TestModel9) and self.intr == other.intr
                and self.double == other.double
                and self.created_date == other.created_date
                and self.geojson == other.geojson)
class TestModel7_2(BigQueryModel):

    __tablename__ = 'unittest2.test7'

    id = Column(Integer)

    def __eq__(self, other):
        # typically __eq__ will also check that the classes match
        return other.id == self.id
class TestModel6(BigQueryModel):

    __tablename__ = 'unittest.test6'

    intr = Column('intr_label', Integer)
    intr_def_lab = Column('intr_def_label', Integer, nullable=False, default=5)
    double = Column(sqlalchemy.Float)
    boolean = Column(sqlalchemy.Boolean, nullable=False)
    string = Column(String(10))
    created_date = Column(sqlalchemy.DateTime,
                          nullable=False,
                          default=datetime.datetime.utcnow)
    wkt = Column(GeographyWKT, nullable=True)
    geojson = Column(GeographyGeoJson, nullable=True)
class TestModel5(BigQueryModel):

    __tablename__ = 'unittest.test5'

    intr = Column(Integer)
    double = Column(sqlalchemy.Float)
    boolean = Column(sqlalchemy.Boolean, nullable=False)
    string = Column(String(10))  # Give maximum length
    created_date = Column(sqlalchemy.DateTime,
                          nullable=False,
                          default=datetime.datetime.utcnow)
    wkt = Column(GeographyWKT, nullable=True)
    geojson = Column(GeographyGeoJson, nullable=True)
Exemple #15
0
class TestModelCluster2(BigQueryModel):

    __tablename__ = 'unittest.table_test_cluster2'

    __table_args__ = {'info': {'bigquery_cluster_by': ['string']}}

    intr = Column(Integer)
    double = Column(sqlalchemy.Float)
    boolean = Column(sqlalchemy.Boolean, nullable=False)
    string = Column(String(10))  # Give maximum length
    created_date = Column(sqlalchemy.DateTime,
                          nullable=False,
                          default=datetime.datetime.utcnow)
    wkt = Column(GeographyWKT, nullable=True)
    geojson = Column(GeographyGeoJson, nullable=True)