This file contains hidden or 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 DataLoader(object): | |
| def __init__(self, image_size, batch_size): | |
| self.image_size = image_size | |
| self.batch_size = batch_size | |
| # 80% train data, 10% validation data, 10% test data | |
| split_weights = (8, 1, 1) | |
| splits = tfds.Split.TRAIN.subsplit(weighted=split_weights) | |
This file contains hidden or 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
| user.delete() |
This file contains hidden or 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
| user.name = "Marko" | |
| # Update | |
| user.save() |
This file contains hidden or 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
| read_users = User.objects | |
| for user in User.objects: | |
| print("Name: {}; Age: {}; Blog: {}".format(user.name, user.age, user.blog)) |
This file contains hidden or 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
| user = User( | |
| name = "Rubik", | |
| age = 33, | |
| blog = "rubikscode.net") | |
| # Create Operation | |
| user.save() |
This file contains hidden or 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(Document): | |
| name = StringField(required=True, max_length=50) | |
| age = IntField(required=True) | |
| blog = StringField(required=True, max_length=50) |
This file contains hidden or 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
| from mongoengine import * | |
| connect('local', host='localhost', port=27017) |
This file contains hidden or 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
| result = user_repo.delete_many({'blog':'rubikscode.net'}) | |
| print(result.acknowledged) |
This file contains hidden or 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
| result = user_repo.delete({'name':'Nikola'}) | |
| print(result.acknowledged) |
This file contains hidden or 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 UserRepository(object): | |
| def __init__(self): | |
| mongoclient = MongoClient('localhost', 27017) | |
| #mongoclient = MongoClient('mongodb://localhost:27017') | |
| database = mongoclient.local | |
| self._users = database.user | |
| # Create operations | |
| def insert(self, user): |