当前位置: 首页>>代码示例>>Python>>正文


Python Database.remove方法代码示例

本文整理汇总了Python中src.common.database.Database.remove方法的典型用法代码示例。如果您正苦于以下问题:Python Database.remove方法的具体用法?Python Database.remove怎么用?Python Database.remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在src.common.database.Database的用法示例。


在下文中一共展示了Database.remove方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: remove_from_db

# 需要导入模块: from src.common.database import Database [as 别名]
# 或者: from src.common.database.Database import remove [as 别名]
 def remove_from_db(self):
     if self._feed:
         news = [article for article in Database.find("articles", {"page_id" : uuid.UUID('{00000000-0000-0000-0000-000000000000}')})]
         for article in news:
             article = Article.get_by_id(article['_id'])
             article.remove_from_db()
     Database.remove(self.COLLECTION, {'_id': self._id})
开发者ID:jslvtr,项目名称:AC41004-Team-2,代码行数:9,代码来源:page.py

示例2: test_one_shift_in_range_returns_none_for_other_days

# 需要导入模块: from src.common.database import Database [as 别名]
# 或者: from src.common.database.Database import remove [as 别名]
    def test_one_shift_in_range_returns_none_for_other_days(self):

        user = User('[email protected]', 'u3', username='u3', _id='u3')
        user.save_to_database()

        # USER HAS SHIFT FOT ONLY MONDAY
        start = beginning_of_week()
        end = start + timedelta(seconds=1)
        # create 1 second shift
        shift = Shift(user._id, start, end)
        shift.save_to_database()

        schedule = Schedule(user._id)

        # Monday is not None
        self.assertEqual(type(schedule.shifts[0]), type(shift))
        self.assertEqual(schedule.row[1], None)
        self.assertEqual(schedule.row[2], None)
        self.assertEqual(schedule.row[3], None)
        self.assertEqual(schedule.row[4], None)
        self.assertEqual(schedule.row[5], None)
        self.assertEqual(schedule.row[6], None)

        Database.remove('users', {'user_id': user._id})
        Database.remove('shifts', {'user_id': user._id})
开发者ID:CodeAmend,项目名称:old-bull-tools,代码行数:27,代码来源:test_schedule.py

示例3: calculate_portfolio

# 需要导入模块: from src.common.database import Database [as 别名]
# 或者: from src.common.database.Database import remove [as 别名]
    def calculate_portfolio(self, portfolio_id):
        finance_data = Database.find_one('financedata', {"portfolio_id": self.portfolio_id})
        if finance_data is not None:
            Database.remove('financedata', {"portfolio_id": self.portfolio_id})
        stock_data = Database.find('stockdata', {"portfolio_id": portfolio_id})
        current_value_list = []
        add_price_list = []
        qty_list = []
        for data in stock_data:
            current_price = (data['current_price'])
            add_price = (data['add_price'])
            qty = (data['qty'])
            current_value_list.append(current_price)
            add_price_list.append(add_price)
            qty_list.append(qty)
        total_qty = sum(qty_list)
        total_current_value = sum(current_value_list)
        total_add_price = sum(add_price_list)
        print(total_current_value)
        try:
            total_purchase_value = total_add_price * total_qty
            total_current_value = total_current_value * total_qty
            percent_change = (total_current_value - total_purchase_value) / total_current_value

            finance = Finance(portfolio_id=portfolio_id, percent_change=percent_change,
                              total_purchase_value=total_purchase_value, total_current_value=total_current_value)
            finance.save_to_database()
        except ZeroDivisionError:
            print("You need to add data first!")
开发者ID:casinelli26,项目名称:Portfolio-App-V4,代码行数:31,代码来源:finance.py

示例4: remove_room

# 需要导入模块: from src.common.database import Database [as 别名]
# 或者: from src.common.database.Database import remove [as 别名]
 def remove_room(self):
     _id = self._id
     Database.remove('pointssetting', {'_id':_id})
     Database.remove('players', {'room_id':_id})
     Database.remove('matches', {'room_id': _id})
     Database.remove('playersall', {'room_id': _id})
     Database.remove(collection='rooms', data=self.json())
     session['_id'] = None
开发者ID:sid-hant,项目名称:tables,代码行数:10,代码来源:room.py

示例5: test_default_values_returns_current_weeks_shifts_even_if_none

# 需要导入模块: from src.common.database import Database [as 别名]
# 或者: from src.common.database.Database import remove [as 别名]
    def test_default_values_returns_current_weeks_shifts_even_if_none(self):
        user = User('[email protected]', 'u1', username='u1', _id='u1')
        user.save_to_database()

        schedule = Schedule(user._id)

        self.assertEqual(len(schedule.row), 7)

        Database.remove('users', {'user_id': user._id})
开发者ID:CodeAmend,项目名称:old-bull-tools,代码行数:11,代码来源:test_schedule.py

示例6: test_save_simple_user_to_db

# 需要导入模块: from src.common.database import Database [as 别名]
# 或者: from src.common.database.Database import remove [as 别名]
    def test_save_simple_user_to_db(self):
        email = "[email protected]"
        user = User(email, "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855")
        user.permissions = Permissions.default().name
        user.save_to_db()

        self.assertIsNotNone(User.find_by_email(email))

        Database.remove("users", {"email": email})
开发者ID:jslvtr,项目名称:AC41004-Team-2,代码行数:11,代码来源:test_user.py

示例7: test_event_register

# 需要导入模块: from src.common.database import Database [as 别名]
# 或者: from src.common.database.Database import remove [as 别名]
    def test_event_register(self):
        user = "Jamie"
        event = Event(title="Test event",
                      description="Test description",
                      start=datetime.datetime.utcnow().strftime('%m/%d/%Y %I:%M %p'),
                      end=(datetime.datetime.utcnow() + datetime.timedelta(hours=1)).strftime('%m/%d/%Y %I:%M %p'),
                      event_type="action",
                      points=10)
        event.save_to_db()

        EventRegister.register_for_event(user, event.get_id())

        self.assertIsNotNone(EventRegister.check_if_registered(user, event.get_id()))

        Database.remove("registrations", {"user": user, "event": event.get_id()})
        Database.remove(Event.COLLECTION, {'_id': event.get_id()})
开发者ID:jslvtr,项目名称:AC41004-Team-2,代码行数:18,代码来源:test_event_registration.py

示例8: test_no_shifts_in_range_returns_none_for_each_day

# 需要导入模块: from src.common.database import Database [as 别名]
# 或者: from src.common.database.Database import remove [as 别名]
    def test_no_shifts_in_range_returns_none_for_each_day(self):
        user = User('[email protected]', 'u2', username='u2', _id='u2')
        user.save_to_database()

        # USER HAS ZERO SHIFTS

        schedule = Schedule(user._id)

        self.assertEqual(schedule.row[0], None)
        self.assertEqual(schedule.row[1], None)
        self.assertEqual(schedule.row[2], None)
        self.assertEqual(schedule.row[3], None)
        self.assertEqual(schedule.row[4], None)
        self.assertEqual(schedule.row[5], None)
        self.assertEqual(schedule.row[6], None)

        Database.remove('users', {'user_id': user._id})
开发者ID:CodeAmend,项目名称:old-bull-tools,代码行数:19,代码来源:test_schedule.py

示例9: test_save_complex_user_to_db

# 需要导入模块: from src.common.database import Database [as 别名]
# 或者: from src.common.database.Database import remove [as 别名]
    def test_save_complex_user_to_db(self):
        email = "[email protected]"
        encrypted_password = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
        country = "Spain"
        university = "Abertay"

        user = User(email, encrypted_password)
        user.data['country'] = country
        user.data['university'] = university
        user.permissions = Permissions.default().name
        user.save_to_db()

        user_from_db = User.find_by_email(email)

        self.assertEqual(user_from_db.email, email)
        self.assertEqual(user_from_db.encrypted_password, encrypted_password)
        self.assertEqual(user_from_db.data['country'], country)
        self.assertEqual(user_from_db.data['university'], university)

        Database.remove("users", {"email": email})
开发者ID:jslvtr,项目名称:AC41004-Team-2,代码行数:22,代码来源:test_user.py

示例10: update_stock_data

# 需要导入模块: from src.common.database import Database [as 别名]
# 或者: from src.common.database.Database import remove [as 别名]
 def update_stock_data(self, ticker, qty):
     stock_data = Database.find_one('stockdata', {"ticker": self.unique_ticker})
     if stock_data is None:
         raise StockDoesNotExist("Stock does not exist in Database")
     else:
         add_price = stock_data['add_price']
         Database.remove('stockdata', query={"ticker": self.unique_ticker})
         from yahoo_finance import Share
         locale.setlocale(locale.LC_ALL, '')
         company = Share(ticker)
         update_price = company.get_price()
         update_price = float(update_price)
         stock = Stock(portfolio_id=self.portfolio_id,
                       ticker=ticker,
                       qty=float(qty),
                       current_price=update_price,
                       add_price=add_price,
                       total_price=float(update_price) * float(qty),
                       percent_change=((float(update_price) - float(add_price)) / float(update_price)))
         stock.save_to_database()
开发者ID:casinelli26,项目名称:Portfolio-App-V4,代码行数:22,代码来源:stock.py

示例11: test_user_attended

# 需要导入模块: from src.common.database import Database [as 别名]
# 或者: from src.common.database.Database import remove [as 别名]
    def test_user_attended(self):
        user = "Jamie"
        event = Event(title="Test event",
                      description="Test description",
                      start=datetime.datetime.utcnow().strftime('%m/%d/%Y %I:%M %p'),
                      end=(datetime.datetime.utcnow() + datetime.timedelta(hours=1)).strftime('%m/%d/%Y %I:%M %p'),
                      event_type="action",
                      points=10)
        event.save_to_db()

        EventRegister.register_for_event(user, event.get_id())

        EventRegister.set_user_attended(user, event.get_id().hex)

        self.assertEquals(EventRegister.get_user_attended(user, event.get_id().hex), True)

        EventRegister.set_user_attended(user, event.get_id().hex)

        self.assertEquals(EventRegister.get_user_attended(user, event.get_id().hex), False)

        Database.remove(Event.COLLECTION, {'_id': event.get_id()})
开发者ID:jslvtr,项目名称:AC41004-Team-2,代码行数:23,代码来源:test_event_registration.py

示例12: test_monday_and_wednesday_day_are_shifts_rest_are_none

# 需要导入模块: from src.common.database import Database [as 别名]
# 或者: from src.common.database.Database import remove [as 别名]
    def test_monday_and_wednesday_day_are_shifts_rest_are_none(self):

        user = User('[email protected]', 'u4', username='u4', _id='u4')
        user.save_to_database()

        # USER HAS SHIFT FOT ONLY MONDAY
        monday = beginning_of_week()
        wednesday = beginning_of_week(days=2)
        # create 1 second shift
        shift = Shift(user._id, monday, monday+timedelta(seconds=1))
        shift.save_to_database()
        shift = Shift(user._id, wednesday, wednesday+timedelta(seconds=1))
        shift.save_to_database()

        schedule = Schedule(user._id)

        # Monday is not None
        self.assertEqual(type(schedule.row[0]), type(shift))
        self.assertEqual(schedule.row[1], None)
        self.assertEqual(type(schedule.row[2]), type(shift))

        Database.remove('users', {'user_id': user._id})
        Database.remove('shifts', {'user_id': user._id})
开发者ID:CodeAmend,项目名称:old-bull-tools,代码行数:25,代码来源:test_schedule.py

示例13: delete

# 需要导入模块: from src.common.database import Database [as 别名]
# 或者: from src.common.database.Database import remove [as 别名]
 def delete(_id):
     Database.remove(SeedConstant.COLLECTION, {'_id':_id})
开发者ID:jslvtr,项目名称:FChat,代码行数:4,代码来源:seed.py

示例14: remove_from_db

# 需要导入模块: from src.common.database import Database [as 别名]
# 或者: from src.common.database.Database import remove [as 别名]
 def remove_from_db(self):
     Database.remove(self.COLLECTION, {'quiz_id': self._quiz_id })
开发者ID:jslvtr,项目名称:AC41004-Team-2,代码行数:4,代码来源:quiz_profile.py

示例15: remove_from_db

# 需要导入模块: from src.common.database import Database [as 别名]
# 或者: from src.common.database.Database import remove [as 别名]
 def remove_from_db(self):
     Database.remove('articles', {'_id': self._id})
开发者ID:jslvtr,项目名称:AC41004-Team-2,代码行数:4,代码来源:article.py


注:本文中的src.common.database.Database.remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。