• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python database.Database类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: update_database

def update_database(genre):


    show = Show(None, None, None, None, None)
    page_no = 0
    titles = show_title(genre, page_no)
    print(titles)
    ratings=find_ratings(titles)
    #print(ratings)
    trailers=find_trailer_link(titles)
    #print(trailers)
    release_dates=show_release_date(genre,page_no)
    poster_link=show_poster_link(genre,page_no)
    i=0
    while i<30:
        show._id=i+1
        show.title=titles[i]
        show.rating=ratings[i]
        show.trailer=trailers[i]
        show.release_date=release_dates[i]
        show.poster=poster_link[i]
        show.save_to_mongo(genre)
        i=i+1
    print("Database Updated")
    Database.remove_all(genre+"_last_updated")
    def json():                                 #can be removed, just done during testing something
        d = str(datetime.date.today())
        return {
            "last_updated_date": d
        }

    Database.insert(genre+"_last_updated", json())
开发者ID:tarunkumarbhati,项目名称:NewShows,代码行数:32,代码来源:app.py


示例2: sync_to_db

 def sync_to_db(self):
     if self._synced is False:
         Database.update(self.COLLECTION,
                         {'quiz_id': self._id, 'user_id': self._id},
                         {'passed': self._passed,
                          'try_number': self._try_number,
                          'last_try': self._last_try,})
开发者ID:jslvtr,项目名称:AC41004-Team-2,代码行数:7,代码来源:quiz_profile.py


示例3: test_one_shift_in_range_returns_none_for_other_days

    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,代码行数:25,代码来源:test_schedule.py


示例4: remove_from_db

 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,代码行数:7,代码来源:page.py


示例5: tester_method

def tester_method():

    email=request.form['email']
    print(email)
    user=User.get_by_email(email)
    Database.update("users",{"email":email},{"printdata":"no"})
    return "done"
开发者ID:hg0605,项目名称:iprint,代码行数:7,代码来源:app.py


示例6: calculate_portfolio

    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,代码行数:29,代码来源:finance.py


示例7: set_user_attended

 def set_user_attended(user, event):
     if EventRegister.get_user_attended(user, event):
         Database.update("registrations", {"user": user, "event": uuid.UUID(event)}, {"$set": {"attended": "No"}},
                         upsert=True)
     else:
         Database.update("registrations", {"user": user, "event": uuid.UUID(event)}, {"$set": {"attended": "Yes"}},
                         upsert=True)
开发者ID:jslvtr,项目名称:AC41004-Team-2,代码行数:7,代码来源:eventregister.py


示例8: remove_room

 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,代码行数:8,代码来源:room.py


示例9: get_registered_events

 def get_registered_events(user):
     events_registered_for = Database.find("registrations", {"user": user})
     if events_registered_for is not None:
         events = list()
         for event in events_registered_for:
             events.append(Database.find_one("events", {"_id": event["event"]}))
         return events
     return None
开发者ID:jslvtr,项目名称:AC41004-Team-2,代码行数:8,代码来源:user.py


示例10: get_all_attended

 def get_all_attended(user):
     events_attended = Database.find("registrations", {"user": user, "attended": "Yes"})
     if events_attended is not None:
         events = list()
         for event in events_attended:
             events.append(Database.find_one("events", {"_id": event["event"]}))
         return events
     return None
开发者ID:jslvtr,项目名称:AC41004-Team-2,代码行数:8,代码来源:user.py


示例11: home

def home(genre = 'comedy'):



    #date=Database.find_coloumn(genre+'_last_updated','last_updated_date')


    #if Database.count_all(genre+'_last_updated') > 0:
    #    if date[0]['last_updated_date']!=str(datetime.date.today()):
    #       update_database(genre)
    #else:
    #    update_database(genre)

    #update_database(genre)
    print("Site Visited")
    t=Database.find_coloumn(genre,"title")
    new_title=[None]*30
    new_trailer = [None] * 30
    new_dates=[None]*30
    new_ratings=[None]*30
    new_poster_links=[None]*30

    i=0
    for title in t:
        new_title[i]=title['title']
        i=i+1
    i=0

    trailers = Database.find_coloumn(genre,"trailer")
    for trailer in trailers:
        new_trailer[i]=trailer['trailer']
        i=i+1

    i=0
    release_dates = Database.find_coloumn(genre, "release_date")
    for date in release_dates:
        new_dates[i] = date['release_date']
        i = i + 1

    i = 0
    ratings = Database.find_coloumn(genre, "rating")
    for rating in ratings:
        new_ratings[i] = rating['rating']
        i = i + 1

    i=0
    poster_links = Database.find_coloumn(genre, "poster")
    for poster_link in poster_links:
        new_poster_links[i] = poster_link['poster']
        i = i + 1


    return render_template('list.html', g_link='https://www.google.com/search?q=',elements=new_title, trailer_links=new_trailer,
                           genres=genres, current_genre=genre,
                           release_dates=new_dates,
                           ratings=new_ratings,
                           poster_links=new_poster_links)
开发者ID:tarunkumarbhati,项目名称:NewShows,代码行数:57,代码来源:app.py


示例12: test_default_values_returns_current_weeks_shifts_even_if_none

    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,代码行数:9,代码来源:test_schedule.py


示例13: test_save_simple_user_to_db

    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,代码行数:9,代码来源:test_user.py


示例14: sync_to_db

 def sync_to_db(self):
     if self._synced is False:
         self._synced = True
         Database.update('articles',
                         {'_id': self._id},
                         {'title': self._title,
                             'summary': self._summary,
                             'page_id': self._page_id,
                             'publication': self._publication,
                             'date': self._date
                         })
开发者ID:jslvtr,项目名称:AC41004-Team-2,代码行数:11,代码来源:article.py


示例15: upload_file

def upload_file():
    if request.method == 'POST':
        f = request.files['document']
        f.save('uploads/' + secure_filename(f.filename))
        Database.update("users",{"email":session['email']},{"printdata":"yes"})
        str="server.py"
        str1="uploads/"+f.filename
        print(str1)
        Popen(["nohup","python",str,str1,f.filename])

    return render_template("home.html")
开发者ID:hg0605,项目名称:iprint,代码行数:11,代码来源:app.py


示例16: sync_to_db

 def sync_to_db(self):
     questions = []
     if self._questions is not None:
         for question in self._questions:
             questions.append(question.to_json())
     Database.update(self.COLLECTION,
                     {'_id': self._id},
                     {'title': self._title,
                      'questions': self._questions,
                      'points': self._points
                      })
开发者ID:jslvtr,项目名称:AC41004-Team-2,代码行数:11,代码来源:quiz.py


示例17: uploader_file

def uploader_file():
    if request.method == 'POST':
        f = request.files['image']
        email=request.form['email']
        f.save('uploads/' + secure_filename(f.filename))
        Database.update("users",{"email":email},{"printdata":"yes"})
        str="server.py"
        str1="uploads/"+f.filename
        print(str1)
        Popen(["nohup","python",str,str1,f.filename])

    return jsonify({"status":"success"})
开发者ID:hg0605,项目名称:iprint,代码行数:12,代码来源:app.py


示例18: find_needing_update

 def find_needing_update(cls, minutes_since_update=AlertConstants.ALERT_TIMEOUT):
     last_updated_limit = datetime.datetime.utcnow() - datetime.timedelta(minutes=minutes_since_update)
     return [cls(**elem) for elem in Database.find(AlertConstants.COLLECTION,
                                                   {"last_checked":
                                                        {"$lte": last_updated_limit},
                                               "active": True
                                                    })]
开发者ID:ashwillwink,项目名称:price-of-chair,代码行数:7,代码来源:alert.py


示例19: get_college

 def get_college(university, college_to_find):
     uni = Database.find_one(COLLECTION, {"name": university})
     colleges = [college for college in uni["colleges"]]
     for college in colleges:
         if college_to_find == college["name"]:
             return college
     return False
开发者ID:jslvtr,项目名称:AC41004-Team-2,代码行数:7,代码来源:university.py


示例20: test_event_register

    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,代码行数:16,代码来源:test_event_registration.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python logger.log函数代码示例发布时间:2022-05-27
下一篇:
Python cgd.Path类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap