Esempio n. 1
0
    def add_node(self, **kwargs):
        """Function for adding nodes"""
        db_session.add(
            OfficeStructure(name=kwargs['name'],
                            parent_id=kwargs.get('parent_id', None),
                            tag_id=kwargs.get('tag_id', None)))

        db_session.commit()
Esempio n. 2
0
 def save(self):
     """Function for saving new objects"""
     db_session.add(self)
     db_session.commit()
Esempio n. 3
0
}, {
    "post":
    "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident."
}]

comments = [{
    "comment": "Such a goood idea"
}, {
    "comment": "So funny cant stop laughing"
}, {
    "comment": "Lol"
}]

for user in users:
    user_obj = User(**user)
    db_session.add(user_obj)
    db_session.commit()

for post in posts:
    post.update(
        {'user_id': random.choice([user.id for user in User.query.all()])})
    post_obj = Post(**post)
    db_session.add(post_obj)
    db_session.commit()
for comment in comments:
    print("Before updatte", comment)
    comment.update(
        {'post_id': random.choice([post.id for post in Post.query.all()])})
    comment.update(
        {'created_by': random.choice([user.id for user in User.query.all()])})
    print("After updatte", comment)
Esempio n. 4
0
 def save(self):
     """Function that saves new objects"""
     db_session.add(self)
     db_session.commit()