Last active
May 11, 2016 00:59
-
-
Save nfarah86/d339bf5e6200bbf258accf7d9b39db16 to your computer and use it in GitHub Desktop.
Set Up The Tables and Relationships
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User(Base): | |
""" user using the hardware """ | |
__tablename__ = "users" | |
id = Column(Integer, primary_key = True) | |
first_name = Column(String(20), nullable = False) | |
last_name = Column(String(40), nullable = False) | |
user_name = Column(String(10),nullable = False) | |
email = Column(String (30), nullable = False) | |
password = Column(String(10), nullable = False) | |
class Contact(Base): | |
""" Users will input name, #, and pic? into a form """ | |
__tablename__ = "contacts" | |
id = Column(Integer, primary_key = True) | |
user_id = Column(Integer, ForeignKey("users.id")) | |
first_name = Column(String(20), nullable = True) | |
last_name = Column(String(40), nullable=True) | |
phone_number = Column(Integer, nullable = True) | |
user = relationship("User", backref=backref("contacts", order_by=id)) | |
class GPS_Location(Base): | |
""" LAT +LONG coordinates will be stored """ | |
__tablename__="coordinates" | |
id = Column(Integer, primary_key = True) | |
user_id = Column(Integer, ForeignKey("users.id"), nullable=False) | |
latitude= Column(Float, nullable = False) | |
longitude = Column(Float, nullable = False) | |
created = Column(DateTime, default=datetime.now, nullable = False) | |
user = relationship("User", backref=backref("coordinates", order_by=id)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment