class Location(db.Model): id = db.Column(db.Integer, primary_key=True) locationName = db.Column(db.String(100), nullable=False) locationAddress = db.Column(db.String(200), nullable=False) def __repr__(self): return self.locationName
class User(db.Model): id = db.Column(db.Integer, primary_key=True) nickname = db.Column(db.String(120), index=True, unique=True) password = db.Column(db.String(255)) ## 1>n relationship to class File, allow file to backref user files = db.relationship('File',backref='user',lazy='dynamic') rank_id = db.Column(db.Integer, db.ForeignKey('rank.id')) mb_used = db.Column(db.Integer) ########## uses flask_login extension @property def is_authenticated(self): return True @property def is_active(self): return True @property def is_anonymous(self): return False def get_id(self): return str(self.id) def __repr__(self): return 'User %r' % (self.nickname)
class User(db.Model, UserMixin): __tablename__ = 'users' id = db.Column(db.Integer, primary_key=True) active = db.Column('is_active', db.Boolean(), nullable=False, server_default='1') # User authentication information. The collation='NOCASE' is required # to search case insensitively when USER_IFIND_MODE is 'nocase_collation'. email = db.Column(db.String(255, collation='NOCASE'), nullable=False, unique=True) email_confirmed_at = db.Column(db.DateTime()) password = db.Column(db.String(255), nullable=False, server_default='') # User information first_name = db.Column(db.String(100, collation='NOCASE'), nullable=False, server_default='') last_name = db.Column(db.String(100, collation='NOCASE'), nullable=False, server_default='') # Define the relationship to Role via UserRoles roles = db.relationship('Role', secondary='user_roles') def __repr__(self): return f"User('{self.email}','{self.password}'"
class ServiceProvider(User): __tablename__ = 'service_provider' id = db.Column(db.Integer, db.ForeignKey('user.id'), primary_key=True) projects = db.relationship('AssociationServiceProviderProject', back_populates='service_provider') proposals = db.relationship('AssociationServiceProviderProposal', back_populates='service_provider') skills = db.Column(db.String(100), nullable=False) curriculum = db.Column(db.String(1000), nullable=False) proposal_id = db.Column(db.Integer, db.ForeignKey('proposal.id')) cost_per_project = db.Column(db.Float, nullable=False) __mapper_args__ = { 'polymorphic_identity': 'service_provider', } def __init__(self, name, email, password, skills, curriculum, cost_per_project): User.__init__(self, name, email, password) self.skills = skills self.curriculum = curriculum self.cost_per_project = cost_per_project def __repr__(self): return "Service Provider('{}', '{}', '{}', '{}', '{}', '{}', '{}')".format( self.id, self.name, self.skills, self.type, self.projects, self.cost_per_project, self.proposals)
class Demand(Base): __tablename__ = 'demand' id = db.Column(db.Integer, primary_key=True, nullable=False) name = db.Column(db.String(100), nullable=False) description = db.Column(db.String(1000), nullable=False) funcionalities = db.Column(db.String(300), nullable=False) platform = db.Column(db.String(100), nullable=False) final_date = db.Column(db.Date, nullable=False) proposals = db.relationship('Proposal', backref='demand', lazy=True) project = db.relationship('Project', backref='demand', lazy=True) client_id = db.Column(db.Integer, db.ForeignKey('client.id'), nullable=False) # project = db.relationship('Project', uselist=False) # project_id = db.Column(db.Integer, db.ForeignKey('project.id')) def __init__(self, name, description, funcionalities, platform, final_date, client_id): self.name = name self.description = description self.funcionalities = funcionalities self.platform = platform self.final_date = final_date self.client_id = client_id def __repr__(self): return "Demand('{}', '{}', '{}', '{}', '{}', '{}', '{}')".format( self.id, self.name, self.description, self.funcionalities, self.platform, self.final_date, self.client_id)
class User(db.Model): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(20), unique=True, nullable=False) email = db.Column(db.String(120), unique=True, nullable=False) password = db.Column(db.String(60), unique=True, nullable=False) def __repr__(self): return f"User('{self.username}', '{self.email}')"
class NoteModel(db.Model): id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(100)) content = db.Column(db.String(255)) def __init__(self, title, content): self.title = title self.content = content
class Category_model(db.Model): __tableName__ = 'category_model' id = db.Column(db.Integer, primary_key = True) routeName = db.Column(db.String(15)) title = db.Column(db.String(15)) def __repr__(self): return ' '.join([id,routeName,title])
class User(db.Model): """ Create user table""" id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(80), unique=True) password = db.Column(db.String(80)) def __init__(self, username, password): self.username = username self.password = password
class User(db.Model): ## you must declare a primary key ## otherwise no foreigh key id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(100), index=True, unique=True) email = db.Column(db.String(100), index=True, unique=True) password_hash = db.Column(db.String(200)) ## add the foregin key ## part one here posts = db.relationship('Post', backref='author', lazy='dynamic')
class User(db.Model): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(80), unique=True, nullable=False) password = db.Column(db.String(120), unique=True, nullable=False) posts = db.relationship('Post', backref='author', lazy=True) def save_to_db(self): db.session.add(self) db.session.commit() def __repr__(self): return '<User %r>' % self.username
class User(db.Model): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(20), unique=True, nullable=False) email = db.Column(db.String(120), unique=True, nullable=False) image_file = db.Column(db.String(20), nullable=False, default='default.jpg') password = db.Column(db.String(60), nullable=False) posts = db.relationship('Post', backref='author', lazy=True) def __repr__(self): return f"User('{self.username}', '{self.email}', '{self.image_file}')"
class Post(db.Model): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(40), nullable=False) userID = db.Column(db.String(20), unique=True, nullable=False) D_o_B = db.Column(db.String(40), nullable=False, default=datetime.utcnow) address = db.Column(db.Text, nullable=False) password = db.Column(db.String(60), nullable=False) user_id = db.Column(db.String(20), db.ForeignKey('user.username'), nullable=False) def __repr__(self): return (self.username)
class Items_model(db.Model): __tableName__ = 'items_model' cate_id = db.Column(db.Integer) item_id = db.Column(db.Integer,primary_key = True) name = db.Column(db.String(40)) imageURL = db.Column(db.String(100)) price = db.Column(db.Integer) def __repr__(self): return ' '.join([cate_id,id,name,imageURL,price])
class Users(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(30)) password = db.Column(db.String(20)) nickname = db.Column(db.String(20)) status = db.Column(db.String(2)) def __init__(self, name, password, nickname): self.name = name self.password = password self.nickname = nickname self.status = 'A'
class User(db.Model): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(20), unique=True, nullable=False) email = db.Column(db.String(120), unique=True, nullable=False) password = db.Column(db.String(60), nullable=False) posts = db.relationship('Post', backref='author', lazy=True) # def __init__(self,email,password): # self.email = email # self.password = password def __repr__(self): return f"User('{self.username}', '{self.email}')"
class User(db.Model): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(20), unique=True, nullable=False) email = db.Column(db.String(120), unique=True, nullable=False) image_file = db.Column(db.String(20), nullable=False, default='default.jpg') password = db.Column(db.String(60), nullable=False) # The following posts column will be a backref which allows SQLAlchemy to link # a specific user (author) back to a bunch of different posts they wrote posts = db.relationship('Post', backref='author', lazy=True) # Defines the default manner in which our object will be printed out def __repr__(self): return f"User('{self.username}', '{self.email}', '{self.image_file}')"
class User(db.Model): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(80), unique=True) email = db.Column(db.String(120), unique=True) def __init__(self, username, email): self.username = username self.email = email # rpr() şeklinde kulllanıyoruz. Burası rapor veya loglama için kullanılıyor # olmasada olur def __repr__(self): return '<User %r>' % self.username
class Products(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(20)) quantity = db.Column(db.Integer()) price = db.Column(db.Float) description = db.Column(db.String(120)) status = db.Column(db.String(1)) def __init__(self, name, quantity, price, description): self.name = name self.quantity = quantity self.price = price self.description = description self.status = 'A'
class Clients(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(30)) address = db.Column(db.String(80)) contact = db.Column(db.String(40)) telephone = db.Column(db.Integer()) status = db.Column(db.String(1)) def __init__(self, name, address, contact, telephone): self.name = name self.address = address self.contact = contact self.telephone = telephone self.status = 'A'
class User(db.Model, UserMixin): __tablename__ = 'users' id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(25), unique=True, nullable=False) email = db.Column(db.String(255), unique=True, nullable=False) password = db.Column(db.String(60), nullable=False) messages = db.relationship('Message', lazy=True, backref='user') chats = db.relationship('Chat', secondary=chat_user, backref=db.backref('users')) def __repr__(self): return f"<User {self.username} {self.email}>"
class TwitterData(db.Model): __tablename__ = 'twitter_data' #columns: user_id, twitter_username, category, category score td_id = db.Column(db.Integer, primary_key=True) td_ud_id = db.Column(db.Integer) td_twitter_name = db.Column(db.String(15)) td_category = db.Column(db.String(20)) td_category_score = db.Column(db.Float(10)) def __init__(self, ud_id, twitter_name, category, category_score): self.td_ud_id = ud_id self.td_twitter_name = twitter_name self.td_category = category self.td_category_score = category_score
class Employees(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(50)) email = db.Column(db.String(50)) telephone = db.Column(db.Integer()) job = db.Column(db.String(15)) gender = db.Column(db.String(10)) status = db.Column(db.String(2)) def __init__(self, name, email, telephone, job, gender): self.name = name self.email = email self.telephone = telephone self.job = job self.gender = gender self.status = 'A'
class User(db.Model): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(20), unique=True, nullable=False) email = db.Column(db.String(120), unique=True, nullable=False) image_file = db.Column(db.String(20), nullable=False, default='default.jpg') password = db.Column(db.String(60), nullable=False) posts = db.relationship( 'Post', backref='author', lazy=True ) #defines when sqlachemy loads the data from the db. True means #sqlalchemy will load the data as necessary in one go. Will use the #post attribute to get the posts posted by an indivudual user #backref 'author' creates a column author in the posts table def __repr__(self): return f"User('{self.username}','{self.email}','{self.image_file}')"
class Post(db.Model): id = db.Column(db.Integer, primary_key=True) body = db.Column(db.String(200)) timestamp = db.Column(db.DateTime, index=True, default=datetime.utcnow) ## this is part of the foreign ## part two add here ## thats why we need the foreign key ## and the name will be 'user' not 'User' user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
class File(db.Model): id = db.Column(db.Integer(),primary_key=True) owner = db.Column(db.Integer(),db.ForeignKey('user.id'),index=True) name = db.Column(db.String(255),index=True) size = db.Column(db.Integer,index=True) fext = db.Column(db.String(20),index=True) datetime = db.Column(db.DateTime) public = db.Column(db.Boolean,default=False) public_key = db.Column(db.String(255),index=True) def __init__(self,owner=None,name=None,size=None,fext=None,public=None,public_key=None): self.datetime = datetime.utcnow() self.owner = owner self.name = name self.size = size self.fext = fext self.public = public self.public_key = public_key
class Chat(db.Model): __tablename__ = 'chats' id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(50), nullable=False) messages = db.relationship('Message', lazy=True, backref='chat') def __repr__(self): return f"<Chat {self.name}>"
class Post(db.Model): id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(100), nullable=False) date_posted = db.Column(db.DateTime, nullable=False,default=datetime.utcnow) content = db.Column(db.Text, nullable=False) user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False) def __repr__(self): return f"Post('{self.title}', '{self.date_posted}')"
class User(Base): __tablename__ = 'user' id = db.Column(db.Integer, primary_key=True, nullable=False) name = db.Column(db.String(100), nullable=False) email = db.Column(db.String(120), unique=True, nullable=False) password = db.Column(db.String(30), nullable=False) type = db.Column(db.String(20), nullable=False) def __init__(self, name, email, password): self.name = name self.email = email self.password = password def __repr__(self): return "User('{}', '{}', '{}', '{}')".format(self.id, self.name, self.email, self.type) __mapper_args__ = {'polymorphic_identity': 'user', 'polymorphic_on': type}
class Prospect(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(120), nullable=True) email = db.Column(db.String(120), nullable=False) gender = db.Column(db.String(20), nullable=False) age = db.Column(db.Integer, nullable=False) for_event = db.Column(db.String(120), nullable=False) def __repr__(self): return '<Prospect %r>' % self.name def to_dict(self): return { 'email': self.email, 'age': self.age, 'gender': self.gender, 'name': self.name, 'for_event': self.for_event }