class Publisher(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.Unicode(), nullable=False, index=True) title = db.Column(db.Unicode()) category = db.Column(db.Unicode()) datasets = db.relationship('Dataset', backref='publisher', lazy='dynamic')
class Spend(db.Model): id = db.Column(db.Integer, primary_key=True) OrganisationLabel = db.Column(db.Unicode()) OrganisationalUnit = db.Column(db.Unicode()) TransactionNumber = db.Column(db.Unicode()) BeneficiaryName = db.Column(db.Unicode()) ExpenseType = db.Column(db.Unicode()) PaymentDate = db.Column(db.Unicode()) Amount = db.Column(db.Float()) def get_columns(self): return [ "OrganisationLabel", "OrganisationalUnit", #"TransactionNumber", "BeneficiaryName", "ExpenseType", "PaymentDate", "Amount", ] def to_dict(self): data = { k: self.__dict__[k] for k in sorted(self.__dict__) if '_sa_' != k[:4] and not k == 'point' } data['Amount'] = '{:20,.2f}'.format(data['Amount']) return data
class Codepoint(db.Model): id = db.Column(db.Integer, primary_key=True) postcode = db.Column(db.Unicode(), nullable=False, index=True) quality = db.Column(db.Unicode()) country = db.Column(db.Unicode()) nhs_region = db.Column(db.Unicode()) nhs_authority = db.Column(db.Unicode()) county = db.Column(db.Unicode()) district = db.Column(db.Unicode()) ward = db.Column(db.Unicode()) geom = db.Column(Geography(spatial_index=False)) @property def lat(self): return to_shape(self.geom).y @property def lon(self): return to_shape(self.geom).x
class Dataset(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.Unicode(), nullable=False, index=True) title = db.Column(db.Unicode()) description = db.Column(db.Unicode()) publisher_id = db.Column(db.Integer, db.ForeignKey('publisher.id')) issue_date = db.Column(db.Unicode()) update_date = db.Column(db.Unicode()) next_update_date = db.Column(db.Unicode()) theme = db.Column(db.Unicode()) temporal_coverage = db.Column(db.Unicode()) schema = db.Column(db.Unicode()) is_super = db.Column(db.Boolean())
class Carpark(db.Model): id = db.Column(db.Integer, primary_key=True) auto_id = db.Column(db.Integer()) name = db.Column(db.Unicode()) operator = db.Column(db.Unicode()) scheme_status = db.Column(db.Unicode()) part_time_award = db.Column(db.Unicode()) phone = db.Column(db.Unicode()) street = db.Column(db.Unicode()) street_2 = db.Column(db.Unicode()) street_3 = db.Column(db.Unicode()) town = db.Column(db.Unicode()) county = db.Column(db.Unicode()) postcode = db.Column(db.Unicode()) physical_type = db.Column(db.Unicode()) payment_type = db.Column(db.Unicode()) spaces = db.Column(db.Integer()) disabled_spaces = db.Column(db.Integer()) cycles = db.Column(db.Unicode()) motobike = db.Column(db.Unicode()) cars = db.Column(db.Unicode()) bus = db.Column(db.Unicode()) coach = db.Column(db.Unicode()) truck_parking_area = db.Column(db.Unicode()) longitude = db.Column(db.Unicode()) latitude = db.Column(db.Unicode()) point = db.Column(Geography('POINT', spatial_index=False)) def get_columns(self): return [ 'name', 'operator', 'street', 'town', 'county', 'spaces', 'latitude', 'longitude' ] def to_dict(self): return {k:self.__dict__[k] for k in sorted(self.__dict__) if '_sa_' != k[:4] and not k == 'point'}