Esempio n. 1
0
class EthContact(db.Model):
    __tablename__ = 'eth_contact'
    address = db.Column(db.String(42), primary_key=True)
    name = db.Column(db.String(255), index=True)
    desc = db.Column(db.String(255))
    email = db.Column(db.String(255), index=True)
    phone = db.Column(db.String(255), index=True)
    eth_balance = db.Column(db.Float(), default=0)
    ogn_balance = db.Column(db.Float(), default=0)
    dai_balance = db.Column(db.Float(), default=0)
    investor = db.Column(db.Boolean())
    presale_interest = db.Column(db.Boolean())
    dapp_user = db.Column(db.Boolean())
    employee = db.Column(db.Boolean())
    exchange = db.Column(db.Boolean())
    company_wallet = db.Column(db.Boolean())
    investor_airdrop = db.Column(db.Boolean())
    token_count = db.Column(db.Integer())
    transaction_count = db.Column(db.Integer())
    tokens = db.Column(JSONB)
    last_updated = db.Column(db.DateTime(),
                             server_default=db.func.now(),
                             onupdate=db.func.now())
    created_at = db.Column(db.DateTime(timezone=True),
                           server_default=db.func.now())
    country_code = db.Column(db.String(2))

    def __str__(self):
        return '%s' % (self.name)
Esempio n. 2
0
class Item(db.Model):
    __tablename__ = 'Items'
    sku = db.Column('SKU', db.Integer(), primary_key=True)
    title = db.Column('title', db.String(256))
    description = db.Column('description', db.String(256))
    category = db.Column('category', db.String(256))
    quantity = db.Column('quantity', db.Integer())
    price = db.Column('price', db.Float())
    rating = db.Column('rating', db.Float())
    seller = db.Column('seller', db.Integer(), ForeignKey('Sellers.id'))
    image = db.Column('image', db.String(256))

    @staticmethod
    def updateItem(title, description, category, quantity, price, image, sku):
        db.session.execute('UPDATE Items SET title = :title, description = :description, category = :category, quantity = '
                           ':quantity, price = :price, image = :image WHERE sku = :sku',
                           {'title': title, 'description': description, 'category': category, 'quantity': quantity,
                            'price': price, 'image': image, 'sku': sku})
        print("Item updated")
        db.session.commit()
    def __init__(self, sku=None, title=None, description=None, category=None,
                 quantity=None, price=None, rating=None, seller=None, image=None):
        self.sku = sku
        self.title = title
        self.description = description
        self.category = category
        self.quantity = quantity
        self.price = price
        self.rating = rating
        self.seller = seller
        self.image = image

    def __repr__(self):
        return '<Item %r>' % self.model
class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    admin = db.Column(db.Boolean, default=False)
    username = db.Column(db.String(50), unique=True)
    first_name = db.Column(db.String(50))
    last_name = db.Column(db.String(50))
    password = db.Column(db.String(80))
    goal_daily_calories = db.Column(db.Float(), default=0)
    goal_daily_protein = db.Column(db.Float(), default=0)
    goal_daily_carbohydrates = db.Column(db.Float(), default=0)
    goal_daily_fat = db.Column(db.Float(), default=0)
    goal_daily_activity = db.Column(db.Float(), default=0)
    application = db.relationship('Application',
                                  backref='user',
                                  lazy=True,
                                  uselist=False)

    def data(self):
        return {
            'username': self.username,
            'firstName': self.first_name,
            'lastName': self.last_name,
            'goalDailyActivity': self.goal_daily_activity,
            'goalDailyCalories': self.goal_daily_calories,
            'goalDailyProtein': self.goal_daily_protein,
            'goalDailyCarbohydrates': self.goal_daily_carbohydrates,
            'goalDailyFat': self.goal_daily_fat,
            'admin': self.admin
        }
Esempio n. 4
0
class DonationModel(db.Model):
    __tablename__ = "donations"

    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.Integer, db.ForeignKey("users.id"), nullable=False)
    attendance_id = db.Column(db.Integer,
                              db.ForeignKey("attendances.id"),
                              nullable=False)
    transfer_id = db.Column(db.Integer,
                            db.ForeignKey("transfers.id"),
                            nullable=True)
    year = db.Column(db.Integer, nullable=False)
    month = db.Column(
        db.Enum("january",
                "february",
                "march",
                "april",
                "may",
                "june",
                "july",
                "august",
                "september",
                "october",
                "november",
                "december",
                name="month"))
    mmk_amount = db.Column(db.Float())
    jpy_amount = db.Column(db.Float())
    paid_at = db.Column(db.DateTime(), nullable=True)

    def __init__(self, user_id: int, attendance_id: int, transfer_id: int,
                 year: int, month: str, mmk_amount: float, jpy_amount: float,
                 paid_at: datetime) -> None:
        self.user_id = user_id
        self.attendance_id = attendance_id
        self.transfer_id = transfer_id
        self.year = year
        self.month = month
        self.mmk_amount = mmk_amount
        self.jpy_amount = jpy_amount
        self.paid_at = paid_at

    def __repr__(self):
        return f"<Donation Records for user_id {self.user_id}>"

    @staticmethod
    def create_donation(new_donation) -> bool:
        """
        create  new_donation
        :param new_donation:
        :return: bool
        """
        try:
            db.session.add(new_donation)
            db.session.commit()
            return True
        except SQLAlchemyError as e:
            # to put log
            return False
Esempio n. 5
0
class GeneListEntry(BioModel):
    gene_list_id = db.Column(db.Integer, db.ForeignKey('genelist.id'))

    p = db.Column(db.Float(precision=53))
    fdr = db.Column(db.Float(precision=53))

    gene_id = db.Column(db.Integer, db.ForeignKey('gene.id'))
    gene = db.relationship('Gene')
Esempio n. 6
0
class City(db.Model):
    __tablename__ = 'cities'

    id = db.Column(db.Integer, primary_key=True)
    state = db.Column(db.String(2), nullable=False)
    name = db.Column(db.String(50), nullable=False)
    latitude = db.Column(db.Float(53), nullable=False)
    longitude = db.Column(db.Float(53), nullable=False)
Esempio n. 7
0
class Product(db.Model):
    __tablename__ = "product"
    id = db.Column(db.String(36),
                   default=lambda: str(uuid4()),
                   primary_key=True)
    name = db.Column(db.String(80), nullable=False)
    description = db.Column(db.String(240), nullable=False)
    price = db.Column(db.Float(10), nullable=False)
    categories = db.relationship("Category", back_populates="product")

    @validates('name')
    def name_validate(self, key, name: str):
        if not name:
            raise ConflictException(msg='Product name is empty')
        return name

    @validates('description')
    def description_validate(self, key, description: str):
        if not description:
            raise ConflictException(msg='Product description is empty')
        return description

    @validates('price')
    def price_validate(self, key, price: str):
        if not price:
            raise ConflictException(msg='Product price is empty')
        if re.findall('[a-zA-Z_+-,@#$%¨&*^~`´]', price):
            raise ConflictException(
                msg='Use only numbers and point in product price')
        return price
class GoogleAnalyticsExperimentVariation(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    created = db.Column(db.DateTime, default=datetime.datetime.now())
    url = db.Column(db.String)
    status = db.Column(db.String)
    name = db.Column(db.String)
    weight = db.Column(db.Float(5))
    experiment_id = db.Column(db.Integer,
                              db.ForeignKey('google_analytics_experiment.id'))
    won = db.Column(db.Boolean)

    def __init__(self, url, status, weight, won, name):
        self.url = url
        self.status = status
        self.weight = weight
        self.won = won
        self.name = name

    def as_dict(self):
        return {
            "name": self.name,
            "url": self.url,
            "won": self.won,
            "status": self.status
        }
Esempio n. 9
0
class ItemModel(db.Model):

    __tablename__ = 'items'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(80))
    price = db.Column(db.Float(precision=2))

    def __init__(self, name, price):
        self.name = name
        self.price = price

    def json(self):
        return {'name' : self.name, 'price' : self.price}

    def save_to_database(self):
         db.session.add(self)
         db.session.commit()

    def delete_from_database(self):
        db.session.delete(self)
        db.session.commit()

    @classmethod
    def fetchAllItems(cls):
       # return {'items' : list(map(lambda item: item.json(), ItemModel.query.all()))}
        return {'items' : [item.json() for item in ItemModel.query.all()]}
   
    @classmethod
    def find_by_ItemName(cls, name):
        return cls.query.filter_by(name = name).first()
Esempio n. 10
0
class TripModel(db.Model):
    __tablename__ = 'trip'

    trip_id = db.Column(db.Integer, primary_key=True)
    destination = db.Column(db.String(100))
    price = db.Column(db.Float(precision=2))
    customer_username = db.Column(db.ForeignKey('customers.username'))
    customer = db.relationship('CustomerModel')

    trips = db.relationship('TripModel')

    def __init__(self, trip_id, destination, price, customer_username):
        self.trip_id = trip_id
        self.destination = destination
        self.price = price
        self.customer_username = customer_username

    def find_by_trip_id(self, trip_id):
        return TripModel.query.filter_by(trip_id=trip_id).first()

    def json(self):
        return {
            'trip_id': self.trip_id,
            'destination': self.destination,
            'price': self.price,
            'customer_username': self.customer_username
        }

    def create_trip(self):
        db.session.add(self)
        db.session.commit()

    def delete_from_database(self):
        db.session.delete(self)
        db.session.commit()
Esempio n. 11
0
class ExtrafundModel(db.Model):
    __tablename__ = "extrafunds"

    id = db.Column(db.Integer, primary_key=True)
    mmk_amount = db.Column(db.Float())
    transfer_id = db.Column(db.Integer,
                            db.ForeignKey("transfers.id"),
                            nullable=False)

    def __init__(self, mmk_amount: float, transfer_id: int) -> None:
        self.mmk_amount = mmk_amount
        self.transfer_id = transfer_id

    def __repr__(self):
        return f"<Extrafund for transfer_id {self.transfer_id}>"

    @staticmethod
    def create_extra_fund(new_extra_fund) -> bool:
        """
        create new extra fund for yen mmk price
        :param new_extra_fund:
        :return: bool
        """
        try:
            db.session.add(new_extra_fund)
            db.session.commit()
            return True
        except SQLAlchemyError as e:
            # to put log
            return False
Esempio n. 12
0
class ItemModel(db.Model):
    __tablename__ = 'items'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(90), nullable=False, unique=True)
    price = db.Column(db.Float(precision=2), nullable=False)
    store_id = db.Column(db.Integer,
                         db.ForeignKey('stores.id'),
                         nullable=False)
    store = db.relationship('StoreModel')

    @classmethod
    def find_by_name(cls, name: str) -> 'ItemModel':
        return cls.query.filter_by(name=name).first()

    def save_to_db(self):
        db.session.add(self)
        db.session.commit()

    def delete_from_db(self):
        db.session.delete(self)
        db.session.commit()

    @classmethod
    def find_all(cls) -> List['ItemModel']:
        return cls.query.all()
Esempio n. 13
0
class ProductModel(db.Model):

    __tablename__ = 'products'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(128), nullable=False, unique=True)
    description = db.Column(db.Text(), nullable=False)
    price = db.Column(db.Float(precision=2), nullable=False)
    categories = db.relationship('ProductCategory', lazy=True)

    def save_to_db(self):
        db.session.add(self)
        db.session.commit()

    def delete_from_db(self):
        db.session.delete(self)
        db.session.commit()

    @classmethod
    def find_by_name(cls, name):
        return cls.query.filter_by(name=name).first()

    @classmethod
    def get_all_products(cls):
        return cls.query.all()

    def __repr__(self):
        return f"<Product {self.name} >"
Esempio n. 14
0
def create_product_review(current_user,product_id):

    if not current_user.admin:
        return create_response({'message':'Permission denied!'},403,'*')

    product = Product.query.filter_by(id=product_id).first()
    if not product:
        return create_response({'message':'Product not found!'},404,'*')

    data = request.get_json()

    try:
        date = data['date']
    except:
        date = None

    product_id = db.Column(db.Integer, db.ForeignKey('product.id'))
    title = db.Column(db.String(50),default='Review')
    stars = db.Column(db.Float(),default=2.5)
    text = db.Column(db.String(16000000),default='<Product Review Text>')

    review = Review(product_id=product.id,
                    title=data.get('title',None),
                    stars=data.get('stars',None),
                    text=data.get('text',None))

    db.session.add(review)
    product.reviews.append(review)
    db.session.commit()

    return create_response({'message':'Review added!','id':review.id},200,'*')
Esempio n. 15
0
class Category(db.Model):
    __tablename__ = 'categories'

    id = db.Column(db.String(36),
                   default=lambda: str(uuid4()),
                   primary_key=True)
    active = db.Column(db.Boolean(), default=True)
    name = db.Column(db.String(80), unique=True, nullable=False)
    profit_percentage = db.Column(db.Float(), nullable=False)
    on_create = db.Column(db.DateTime, default=datetime.datetime.now)
    on_update = db.Column(db.DateTime,
                          default=datetime.datetime.now,
                          onupdate=datetime.datetime.now)

    def serialize(self) -> Dict[str, Union[bool, str]]:
        return {
            'id': self.id,
            'active': self.active,
            'name': self.name,
            'profit_percentage': self.profit_percentage,
            'on_create': self.on_create,
            'on_update': self.on_update
        }

    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        validating_empty_fields([], **kwargs)
        validating_if_field_is_not_str(
            ['active', 'on_create', 'on_update', 'profit_percentage'],
            **kwargs)
        validating_if_field_is_bool(['active'], **kwargs)
        validating_if_field_is_alpha(['name'], **kwargs)
        validating_if_field_is_float(['profit_percentage'], **kwargs)
        validating_size_of_fields(**kwargs)
class Product(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(50), default='New Product')
    image = db.Column(db.String(50), default='https://via.placeholder.com/350')
    price = db.Column(db.Float(), default=5.0)
    description = db.Column(db.String(16000000),
                            default='<Product Description Text>')
    tags = db.relationship('Tag',
                           secondary=product_tag_link,
                           lazy='subquery',
                           backref=db.backref('products', lazy=True))
    reviews = db.relationship('Review', backref='product', lazy=True)
    category_title = db.Column(db.Integer, db.ForeignKey('category.title'))
    cart = db.relationship('Cart', backref='product', lazy=True)

    def data(self):
        try:
            category = self.category.data()
        except:
            category = None
        return {
            'id': self.id,
            'name': self.name,
            'image': self.image,
            'price': self.price,
            'description': self.description,
            'category': category
        }
Esempio n. 17
0
class ItemModel(db.Model):
    __tablename__ = "items"

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(80))
    price = db.Column(db.Float(precision=2))

    store_id = db.Column(db.Integer, db.ForeignKey("stores.id"))
    store = db.relationship("StoreModel")

    def __init__(self, name: str, price: str, store_id: int):
        self.name = name
        self.price = price
        self.store_id = store_id

    def json(self):
        return {"name": self.name, "price": self.price}

    @classmethod
    def find_by_name(cls, name):
        return cls.query.filter_by(name=name).first()

    def save_to_db(self):
        db.session.add(self)
        db.session.commit()

    def delete_from_db(self):
        db.session.delete(self)
        db.session.commit()
Esempio n. 18
0
class Category(db.Model):
    __tablename__ = 'category'

    id = db.Column(db.String(36),
                   primary_key=True,
                   default=lambda: str(uuid4()))
    name = db.Column(db.String(80))
    profit_percent = db.Column(db.Float(2), default=0.0)
    created_at = db.Column(db.DateTime(timezone=True), default=func.now())
    updated_at = db.Column(db.DateTime(timezone=True), onupdate=func.now())
    is_active = db.Column(db.Boolean, unique=False, default=True)
    deleted_at = db.Column(db.DateTime(timezone=True), default=None)
    product_line = db.relationship('ProductLine', backref='product_line')

    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        for keys in kwargs:
            if keys == 'id' or keys == 'name':
                if kwargs[keys] is None or kwargs[keys] == '':
                    raise NullOrNoneValueException(f'The {keys} is empty')

    def serialize(self) -> dict:
        return {
            "id": self.id,
            "name": self.name,
            "profit_percent": self.profit_percent,
            "created_at": self.created_at,
            "updated_at": self.updated_at,
            "is_active": self.is_active,
            "deleted_at": self.deleted_at
        }
Esempio n. 19
0
class ItemModel(db.Model):
    __tablename__ = 'items'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(80))
    price = db.Column(db.Float(precision=2))
    store_id = db.Column(db.Integer, db.ForeignKey('stores.id'))
    store = db.relationship('StoreModel')

    #this init method creates an item model, so the item it is dealing with is the item itself
    def __init__(self, name, price, store_id):
        self.name = name
        self.price = price
        self.store_id = store_id

    def json(self):
        return {'name': self.name, 'price': self.price}

    @classmethod
    def find_item_by_name(cls, name):
        #query object inherited from SQLAlchemy object in ItemModel
        return cls.query.filter_by(
            name=name).first()  #SELECT * FROM items WHERE name = name LIMIT 1

        #sqlAlchemy will do an update instead of an insert,
        # because if something was called using an id, it just rewrites it?
        #this method is good for updating and inserting data
    def save_to_db(self):
        db.session.add(
            self
        )  #session is a collection of objects that we will write into the database
        db.session.commit()

    def delete_from_db(self):
        db.session.delete(self)
        db.session.commit()
Esempio n. 20
0
class Funded(db.Model):
    __tablename__ = "funded"
    event_id = db.Column(db.Integer, ForeignKey('event.id'), primary_key=True)
    user_id = db.Column(db.Integer, ForeignKey('user.id'), primary_key=True)
    fund_amount = db.Column(db.Float())
    backers = db.relationship("Event", back_populates="backers")
    backed = db.relationship("User", back_populates="backed")
Esempio n. 21
0
class ItemModel(db.Model):
    __tablename__ = 'items'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(80))
    price = db.Column(db.Float(precision=2))

    store_id = db.Column(db.Integer, db.ForeignKey('stores.id'))
    stores = db.relationship('StoreModel')

    def __init__(self, name, price, store_id):
        self.name = name
        self.price = price
        self.store_id = store_id

    def json(self):
        return {
            'name': self.name,
            'price': self.price,
            'store_id': self.store_id
        }

    @classmethod
    def get_item_by_name(cls, name):
        return cls.query.filter_by(name=name).first(
        )  # SELECT * FROM __tablename__ WHERE name = name LIMIT 1

    def save_to_db(self):
        db.session.add(self)
        db.session.commit()

    def del_from_db(self):
        db.session.delete(self)
        db.session.commit()
Esempio n. 22
0
class Hotel(db.Model):
    __tablename__ = 'hoteis'

    id = db.Column(db.String(36), primary_key=True, nullable=False)
    nome = db.Column(db.String(128), nullable=False)
    estrelas = db.Column(db.Float(precision=1), nullable=True)
    diaria = db.Column(db.Float(precision=2), nullable=True)
    cidade = db.Column(db.String(40), nullable=False)

    def serialize(self) -> dict:
        return {
            'id': self.id,
            'nome': self.nome,
            'estrelas': self.estrelas,
            'diaria': self.diaria,
            'cidade': self.cidade
        }
class Activity(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.Integer)
    name = db.Column(db.String(50), default='New Activity')
    duration = db.Column(db.Float(), default=0)
    date = db.Column(db.DateTime(),
                     default=lambda: datetime.datetime.now(tzinfo))
    calories = db.Column(db.Float(), default=0)

    def data(self):
        return {
            'id': self.id,
            'name': self.name,
            'duration': self.duration,
            'date': self.date.isoformat(),
            'calories': self.calories
        }
Esempio n. 24
0
class TransferModel(db.Model):
    __tablename__ = "transfers"
    id = db.Column(db.Integer, primary_key=True)
    year = db.Column(db.Integer, nullable=False)
    month = db.Column(
        db.Enum("january",
                "february",
                "march",
                "april",
                "may",
                "june",
                "july",
                "august",
                "september",
                "october",
                "november",
                "december",
                name="transfer_month"))
    total_mmk = db.Column(db.Float())
    total_jpy = db.Column(db.Float())

    def __init__(self, year: int, month: str, total_mmk: float,
                 total_jpy: float) -> None:
        self.year = year
        self.month = month
        self.total_mmk = total_mmk
        self.total_jpy = total_jpy

    def __repr__(self):
        return f"<Transfer record for {self.month}>"

    @staticmethod
    def create_transfer(new_transfer) -> bool:
        """
        create new transfer record
        :param new_transfer:
        :return: bool
        """
        try:
            db.session.add(new_transfer)
            db.session.commit()
            return True
        except SQLAlchemyError as e:
            # to put log
            return False
class Food(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    meal_id = db.Column(db.Integer)
    name = db.Column(db.String(50), default='New Food')
    calories = db.Column(db.Float(), default=0)
    protein = db.Column(db.Float(), default=0)
    carbohydrates = db.Column(db.Float(), default=0)
    fat = db.Column(db.Float(), default=0)

    def data(self):
        return {
            'id': self.id,
            'name': self.name,
            'calories': self.calories,
            'carbohydrates': self.carbohydrates,
            'protein': self.protein,
            'fat': self.fat
        }
Esempio n. 26
0
class Seller(db.Model):
    __tablename__ = 'Sellers'
    id = db.Column('id', db.Integer(), ForeignKey('Users.id'), primary_key=True)
    rating = db.Column('rating', db.Float())

    def __init__(self, id=None, rating=None):
        self.id = id
        self.rating = rating

    def __repr__(self):
        return '<Seller %r>' % self.model
Esempio n. 27
0
class CirculatingSupply(db.Model):
    __tablename__ = 'circulating_supply'
    id = db.Column(db.Integer, primary_key=True)
    supply_amount = db.Column(db.Float(), default=0)
    snapshot_date = db.Column(db.DateTime(timezone=True),
                              server_default=db.func.now())
    created_at = db.Column(db.DateTime(timezone=True),
                           server_default=db.func.now())

    def __str__(self):
        return '%s' % (self.name)
Esempio n. 28
0
class Event(db.Model):

    __tablename__ = 'events'

    id = db.Column(db.Integer, primary_key=True)
    activity = db.Column(db.String, nullable=True)
    time = db.Column(db.String, nullable=True)
    latitude = db.Column(db.Float(Precision=64), nullable=True)
    longitude = db.Column(db.Float(Precision=64), nullable=True)
    description = db.Column(db.String, nullable=True)
    category_id = db.Column(db.Integer, nullable=True)
    address = db.Column(db.String, nullable=True)
    privacy = db.Column(db.String, nullable=True)
    n_people = db.Column(db.Integer, nullable=True)
    host_name = db.Column(db.Integer, nullable=True)
    tags = db.Column(db.String, nullable=True)
    cover = db.Column(db.String, nullable=True)

    def to_json(self):
        cat = db.session.query(Category).filter_by(id=self.category_id).all()[0]
        return dict(id=self.id, activity=self.activity, time=self.time, latitude=self.latitude, longitude=self.longitude, description=self.description, category=cat.to_json(), address=self.address, privacy=self.privacy, n_people=self.n_people, host_name=self.host_name, tags=self.tags, cover=self.cover)
Esempio n. 29
0
class WufooTextareaSentiment(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    survey_id = db.Column(db.Integer, db.ForeignKey('wufoo_survey.id'))
    created = db.Column(db.DateTime, default=datetime.datetime.now())
    score = db.Column(db.Float(15), default=0.0)
    sentiment_type = db.Column(db.String)
    text = db.Column(db.Text)

    def __init__(self, score, sentiment_type, text):
        self.score = score
        self.sentiment_type = sentiment_type
        self.text = text
Esempio n. 30
0
class User(db.Model):
    id = db.Column(db.Integer, nullable=False, unique=True, primary_key=True)
    location = db.Column(db.String(500), nullable=False)
    store_name = db.Column(db.String(500), nullable=False)
    lat = db.Column(db.Float(500), nullable=True)
    lng = db.Column(db.Float(500), nullable=True)
    username = db.Column(db.String(500), nullable=False)
    password = db.Column(db.String(500), nullable=False)

    def __init__(self, location, storename, username, password):
        self.location = location
        self.store_name = storename
        data = {'address': location}
        endpoint = "https://maps.googleapis.com/maps/api/geocode/json"
        resp = requests.get(endpoint, params=data)
        latlng = json.loads(resp.text)['results'][0]['geometry']['location']
        self.lat = latlng['lat']
        self.lng = latlng['lng']
        self.username = username
        self.password = password
        print(self.location, self.store_name, self.lat, self.lng,
              self.username, self.password)