當前位置: 首頁>>代碼示例>>Python>>正文


Python func.lower方法代碼示例

本文整理匯總了Python中sqlalchemy.func.lower方法的典型用法代碼示例。如果您正苦於以下問題:Python func.lower方法的具體用法?Python func.lower怎麽用?Python func.lower使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在sqlalchemy.func的用法示例。


在下文中一共展示了func.lower方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: count

# 需要導入模塊: from sqlalchemy import func [as 別名]
# 或者: from sqlalchemy.func import lower [as 別名]
def count(column, value, glob=False):
    """Counts number of rows with value in a column. This function is case-insensitive.

    Positional arguments:
    column -- the SQLAlchemy column object to search in (e.g. Table.a_column).
    value -- the value to search for, any string.

    Keyword arguments:
    glob -- enable %globbing% search (default False).

    Returns:
    Number of rows that match. Equivalent of SELECT count(*) FROM.
    """
    query = db.session.query(func.count('*'))
    if glob:
        query = query.filter(column.ilike(value))
    else:
        query = query.filter(func.lower(column) == value.lower())
    return query.one()[0] 
開發者ID:Robpol86,項目名稱:Flask-Large-Application-Example,代碼行數:21,代碼來源:helpers.py

示例2: get

# 需要導入模塊: from sqlalchemy import func [as 別名]
# 或者: from sqlalchemy.func import lower [as 別名]
def get(self):

        symbols = get_parsed_arg_list('symbols', to_lower=True)
        exchange_pairs = get_parsed_arg_list('exchange_pairs', to_lower=True)

        if len(symbols) > 0:
            tokens = Token.query.filter(func.lower(Token.symbol).in_(symbols)).all()
        else:
            tokens = Token.query.all()

        exchange_pair_tokens = Token.query.filter(func.lower(Token.symbol).in_(exchange_pairs)).all()

        tokens_schema.context = {'exchange_pairs': exchange_pair_tokens}

        response_object = {
            'message': 'success',
            'data': {
                'tokens': tokens_schema.dump(tokens).data
            }
        }

        return make_response(jsonify(response_object)), 200 
開發者ID:teamsempo,項目名稱:SempoBlockchain,代碼行數:24,代碼來源:token_api.py

示例3: find_user

# 需要導入模塊: from sqlalchemy import func [as 別名]
# 或者: from sqlalchemy.func import lower [as 別名]
def find_user(self, case_insensitive=False, **kwargs):
        from sqlalchemy import func as alchemyFn

        query = self.user_model.query
        if config_value("JOIN_USER_ROLES") and hasattr(self.user_model, "roles"):
            from sqlalchemy.orm import joinedload

            query = query.options(joinedload("roles"))

        if case_insensitive:
            # While it is of course possible to pass in multiple keys to filter on
            # that isn't the normal use case. If caller asks for case_insensitive
            # AND gives multiple keys - throw an error.
            if len(kwargs) > 1:
                raise ValueError("Case insensitive option only supports single key")
            attr, identifier = kwargs.popitem()
            subquery = alchemyFn.lower(
                getattr(self.user_model, attr)
            ) == alchemyFn.lower(identifier)
            return query.filter(subquery).first()
        else:
            return query.filter_by(**kwargs).first() 
開發者ID:Flask-Middleware,項目名稱:flask-security,代碼行數:24,代碼來源:datastore.py

示例4: get_subscription

# 需要導入模塊: from sqlalchemy import func [as 別名]
# 或者: from sqlalchemy.func import lower [as 別名]
def get_subscription(application=None):
    """
    Return a list of subscriptions for a certain application
    If application is omitted, all applications are returned.

    :param application: Name of the application
    :return: list of subscription dictionaries
    """
    subscriptions = []
    sql_query = Subscription.query
    if application:
        sql_query = sql_query.filter(func.lower(Subscription.application) ==
                                     application.lower())

    for sub in sql_query.all():
        subscriptions.append(sub.get())

    return subscriptions 
開發者ID:privacyidea,項目名稱:privacyidea,代碼行數:20,代碼來源:subscriptions.py

示例5: get_user

# 需要導入模塊: from sqlalchemy import func [as 別名]
# 或者: from sqlalchemy.func import lower [as 別名]
def get_user( session, broker_id, username=None, email=None, user_id=None ):
    if username:
      username = username.lower().strip()
    if email:
      email = email.lower().strip()


    if user_id:
      filter_obj = or_(User.id == user_id)
    elif username and email:
      filter_obj = or_( func.lower(User.username)==username, func.lower(User.email)==email )
    elif username:
      filter_obj = or_( func.lower(User.username)==username )
    elif email:
      filter_obj = or_( func.lower(User.email)==email )
    else:
      return  None
    user = session.query(User).filter(User.broker_id == broker_id).filter(filter_obj).first()
    if user:
      return  user
    return None 
開發者ID:bitex-coin,項目名稱:backend,代碼行數:23,代碼來源:models.py

示例6: get_all_without_views

# 需要導入模塊: from sqlalchemy import func [as 別名]
# 或者: from sqlalchemy.func import lower [as 別名]
def get_all_without_views(cls, formats=[]):
        '''Returns all resources that have no resource views

        :param formats: if given, returns only resources that have no resource
            views and are in any of the received formats
        :type formats: list

        :rtype: list of ckan.model.Resource objects
        '''
        query = meta.Session.query(cls).outerjoin(ckan.model.ResourceView) \
                    .filter(ckan.model.ResourceView.id == None)

        if formats:
            lowercase_formats = [f.lower() for f in formats]
            query = query.filter(func.lower(cls.format).in_(lowercase_formats))

        return query.all() 
開發者ID:italia,項目名稱:daf-recipes,代碼行數:19,代碼來源:resource.py

示例7: players

# 需要導入模塊: from sqlalchemy import func [as 別名]
# 或者: from sqlalchemy.func import lower [as 別名]
def players():
    form = SearchPlayerForm()
    player_query = Player.query

    if form.validate_on_submit():
        player_query = player_query.join(User)
        if form.player_name.data:
            player_query = player_query.filter(
                func.lower(User.name).contains(form.player_name.data.lower()))
        if form.aga_id.data:
            player_query = player_query.filter(
                User.aga_id == form.aga_id.data)

    players = player_query.limit(100).all()

    return render_template('players.html', players=players, form=form) 
開發者ID:usgo,項目名稱:online-ratings,代碼行數:18,代碼來源:views.py

示例8: test_render_add_index_func

# 需要導入模塊: from sqlalchemy import func [as 別名]
# 或者: from sqlalchemy.func import lower [as 別名]
def test_render_add_index_func(self):
        m = MetaData()
        t = Table(
            "test",
            m,
            Column("id", Integer, primary_key=True),
            Column("code", String(255)),
        )
        idx = Index("test_lower_code_idx", func.lower(t.c.code))
        op_obj = ops.CreateIndexOp.from_index(idx)

        eq_ignore_whitespace(
            autogenerate.render_op_text(self.autogen_context, op_obj),
            "op.create_index('test_lower_code_idx', 'test', "
            "[sa.text(!U'lower(code)')], unique=False)",
        ) 
開發者ID:sqlalchemy,項目名稱:alembic,代碼行數:18,代碼來源:test_autogen_render.py

示例9: get_user_from_google_member

# 需要導入模塊: from sqlalchemy import func [as 別名]
# 或者: from sqlalchemy.func import lower [as 別名]
def get_user_from_google_member(member, db=None):
    """
    Get User object for all members on a Google project by checking db.

    Args:
        member(cirrus.google_cloud.iam.GooglePolicyMember): Member on
            the google project who are of type User

    Return:
        fence.models.User: User from our db for member on Google project
    """
    session = get_db_session(db)

    linked_google_account = (
        session.query(UserGoogleAccount)
        .filter(func.lower(UserGoogleAccount.email) == member.email_id.lower().strip())
        .first()
    )
    if linked_google_account:
        return (
            session.query(User).filter(User.id == linked_google_account.user_id).first()
        )

    return None 
開發者ID:uc-cdis,項目名稱:fence,代碼行數:26,代碼來源:utils.py

示例10: add_foreign_key_constraint_if_not_exist

# 需要導入模塊: from sqlalchemy import func [as 別名]
# 或者: from sqlalchemy.func import lower [as 別名]
def add_foreign_key_constraint_if_not_exist(
    table_name, column_name, fk_table_name, fk_column_name, driver, metadata
):
    table = Table(table_name, metadata, autoload=True, autoload_with=driver.engine)
    foreign_key_name = "{}_{}_fkey".format(table_name.lower(), column_name)

    if column_name in table.c:
        foreign_keys = [fk.name for fk in getattr(table.c, column_name).foreign_keys]
        if foreign_key_name not in foreign_keys:
            with driver.session as session:
                session.execute(
                    'ALTER TABLE "{}" ADD CONSTRAINT {} '
                    'FOREIGN KEY({}) REFERENCES "{}" ({});'.format(
                        table_name,
                        foreign_key_name,
                        column_name,
                        fk_table_name,
                        fk_column_name,
                    )
                )
                session.commit() 
開發者ID:uc-cdis,項目名稱:fence,代碼行數:23,代碼來源:models.py

示例11: _revoke_from_db

# 需要導入模塊: from sqlalchemy import func [as 別名]
# 或者: from sqlalchemy.func import lower [as 別名]
def _revoke_from_db(self, sess, to_delete):
        """
        Revoke user access to projects in the auth database

        Args:
            sess: sqlalchemy session
            to_delete: a set of (username, project.auth_id) to be revoked from db
        Return:
            None
        """
        for (username, project_auth_id) in to_delete:
            q = (
                sess.query(AccessPrivilege)
                .filter(AccessPrivilege.project.has(auth_id=project_auth_id))
                .join(AccessPrivilege.user)
                .filter(func.lower(User.username) == username)
                .all()
            )
            for access in q:
                self.logger.info(
                    "revoke {} access to {} in db".format(username, project_auth_id)
                )
                sess.delete(access) 
開發者ID:uc-cdis,項目名稱:fence,代碼行數:25,代碼來源:sync_users.py

示例12: make_id

# 需要導入模塊: from sqlalchemy import func [as 別名]
# 或者: from sqlalchemy.func import lower [as 別名]
def make_id(namespace, name):
    """
    pass a language name or host in with a name, get a Package.id str
    """

    namespace = namespace.lower()

    if namespace in ["cran", "pypi"]:
        return namespace + ":" + name

    elif namespace == "python":
        return "pypi:" + name

    elif namespace == "r":
        return "cran:" + name

    else:
        raise ValueError("Invalid namespace for package id") 
開發者ID:ourresearch,項目名稱:depsy,代碼行數:20,代碼來源:package.py

示例13: registerCommon

# 需要導入模塊: from sqlalchemy import func [as 別名]
# 或者: from sqlalchemy.func import lower [as 別名]
def registerCommon(request, form):
    mails = request.db.query(models.User.email).all()
    mails = [m.email.lower() for m in mails]
    if form['email'].lower() in mails:
        request.session.flash('Ein Benutzer mit dieser E-Mail-Adresse existiert bereits.', queue='messages')
        return False
    else:
        user = models.User()
        form.obj = user
        form.saveValues()
        request.db.add(user)
        confirmation = models.Confirmation()
        confirmation.source = 'user/register'
        confirmation.user = user
        request.db.add(confirmation)
        request.db.commit()
        send_confirmation_mail(request, user, confirmation)
        return True 
開發者ID:muesli-hd,項目名稱:muesli,代碼行數:20,代碼來源:viewsUser.py

示例14: validateInput

# 需要導入模塊: from sqlalchemy import func [as 別名]
# 或者: from sqlalchemy.func import lower [as 別名]
def validateInput(self):
        '''
        Validate user input.
        '''
        if self._dbmodel:
            if callable(self._dbmodel):
                modelObj = self._dbmodel()
            
            #Then it is a class instance    
            else:
                modelObj = self._dbmodel
                self._dbmodel = self._dbmodel.__class__
                
            objQueryProperty = getattr(self._dbmodel,self._attrName)
            modelRecord = modelObj.queryObject().filter(func.lower(objQueryProperty) == func.lower(self.text())).first()
                                                        
            if modelRecord != None:
                self.setStyleSheet(INVALIDATESTYLESHEET)
                self._currInvalidMsg = self._invalidMsg.format("'" + self.text() + "'")
                self._isValid = False
                
                if self._notifBar:
                    self._notifBar.insertErrorNotification(self._currInvalidMsg) 
開發者ID:gltn,項目名稱:stdm,代碼行數:25,代碼來源:validating_line_edit.py

示例15: grant

# 需要導入模塊: from sqlalchemy import func [as 別名]
# 或者: from sqlalchemy.func import lower [as 別名]
def grant(self, sess, comment, grantee, badge):
        """
        This is how admins can grant badges manually
        """
        author = comment.author.name
        badge = badge.lower().replace('\\', '')
        grantee_unescaped = grantee.replace('\\', '')

        if author in config.ADMIN_ACCOUNTS:
            investor = sess.query(Investor).\
                filter(Investor.name == grantee_unescaped).\
                first()

            if not investor:
                return comment.reply_wrap(message.modify_grant_failure("no such investor"))

            badge_list = json.loads(investor.badges)
            if badge in badge_list:
                return comment.reply_wrap(message.modify_grant_failure("already owned"))

            badge_list.append(badge)
            investor.badges = json.dumps(badge_list)
            return comment.reply_wrap(message.modify_grant_success(grantee, badge)) 
開發者ID:thecsw,項目名稱:memeinvestor_bot,代碼行數:25,代碼來源:comment_worker.py


注:本文中的sqlalchemy.func.lower方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。