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


Python func.now方法代碼示例

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


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

示例1: rename_table

# 需要導入模塊: from sqlalchemy.sql import func [as 別名]
# 或者: from sqlalchemy.sql.func import now [as 別名]
def rename_table(
            cls, operations, old_table_name, new_table_name, schema=None):
        """Emit an ALTER TABLE to rename a table.

        :param old_table_name: old name.
        :param new_table_name: new name.
        :param schema: Optional schema name to operate within.  To control
         quoting of the schema outside of the default behavior, use
         the SQLAlchemy construct
         :class:`~sqlalchemy.sql.elements.quoted_name`.

         .. versionadded:: 0.7.0 'schema' can now accept a
            :class:`~sqlalchemy.sql.elements.quoted_name` construct.

        """
        op = cls(old_table_name, new_table_name, schema=schema)
        return operations.invoke(op) 
開發者ID:jpush,項目名稱:jbox,代碼行數:19,代碼來源:ops.py

示例2: rename_table

# 需要導入模塊: from sqlalchemy.sql import func [as 別名]
# 或者: from sqlalchemy.sql.func import now [as 別名]
def rename_table(
        cls, operations, old_table_name, new_table_name, schema=None
    ):
        """Emit an ALTER TABLE to rename a table.

        :param old_table_name: old name.
        :param new_table_name: new name.
        :param schema: Optional schema name to operate within.  To control
         quoting of the schema outside of the default behavior, use
         the SQLAlchemy construct
         :class:`~sqlalchemy.sql.elements.quoted_name`.

         .. versionadded:: 0.7.0 'schema' can now accept a
            :class:`~sqlalchemy.sql.elements.quoted_name` construct.

        """
        op = cls(old_table_name, new_table_name, schema=schema)
        return operations.invoke(op) 
開發者ID:sqlalchemy,項目名稱:alembic,代碼行數:20,代碼來源:ops.py

示例3: test

# 需要導入模塊: from sqlalchemy.sql import func [as 別名]
# 或者: from sqlalchemy.sql.func import now [as 別名]
def test(self,user,password,token):
        ### now test for bad token usage
        tokenhash = self.tokendb.hashToken(token) 
        if self.tokendb.checkToken(user,tokenhash):
            if self.debug:
                print(" \- - Password is in token library")
            return (10,None)
        else:
            if self.debug:
                print(" \- * Password is not in token library")
        return (0,None) 
開發者ID:CboeSecurity,項目名稱:password_pwncheck,代碼行數:13,代碼來源:pwnpass.py

示例4: verifyPasswordGood

# 需要導入模塊: from sqlalchemy.sql import func [as 別名]
# 或者: from sqlalchemy.sql.func import now [as 別名]
def verifyPasswordGood(self,user,password,ip=None,reserve=True,always_true=False):
        score = 0
        reasons = []
        token = self.tokendb.tokenizePassword(password)
        tokenhash = self.tokendb.hashToken(token) 

        for Test in self.Tests:
            (code,ctx) = Test.test(user,password,token)
            reasons.append(Test.report(code,ctx))
            score += code
        
        reasons = list(filter(lambda x: len(x),reasons))
        if score == 0:
            if reserve == True:
                self.tokendb.addToken(user,tokenhash,ip)
                reasons.append( "Password is valid and now reserved" )
                if self.debug:
                    print(" \- + Password is a valid entry and is now reserved")
            else:
                reasons.append( "Password is tested as valid" )
                if self.debug:
                    print(" \- + Password is tested as valid entry")
            retval = True
        else:
            if self.debug:
                print(" \- - Password is invalid and unacceptable")
            retval = False

        if always_true == True and retval == False:
            print(" \- - OVERRIDING invalid with Valid (yesman enabled)!!!")
            reasons.append( "Invalid Password Approved due to Yesman mode" )
            retval = True
        return (retval,score,'\n'.join(reasons)) 
開發者ID:CboeSecurity,項目名稱:password_pwncheck,代碼行數:35,代碼來源:pwnpass.py

示例5: changed

# 需要導入模塊: from sqlalchemy.sql import func [as 別名]
# 或者: from sqlalchemy.sql.func import now [as 別名]
def changed(cls):
        found = PeriodicTasks.query.filter_by(ident=1).first()
        if not found:
            found = PeriodicTasks()
        found.last_update = datetime.datetime.now()
        db.session.add(found) 
開發者ID:Salamek,項目名稱:gitlab-tools,代碼行數:8,代碼來源:celery.py

示例6: drop_constraint

# 需要導入模塊: from sqlalchemy.sql import func [as 別名]
# 或者: from sqlalchemy.sql.func import now [as 別名]
def drop_constraint(
            cls, operations, constraint_name, table_name,
            type_=None, schema=None):
        """Drop a constraint of the given name, typically via DROP CONSTRAINT.

        :param constraint_name: name of the constraint.
        :param table_name: table name.
        :param type_: optional, required on MySQL.  can be
         'foreignkey', 'primary', 'unique', or 'check'.
        :param schema: Optional schema name to operate within.  To control
         quoting of the schema outside of the default behavior, use
         the SQLAlchemy construct
         :class:`~sqlalchemy.sql.elements.quoted_name`.

         .. versionadded:: 0.7.0 'schema' can now accept a
            :class:`~sqlalchemy.sql.elements.quoted_name` construct.

        .. versionchanged:: 0.8.0 The following positional argument names
           have been changed:

           * name -> constraint_name

        """

        op = cls(constraint_name, table_name, type_=type_, schema=schema)
        return operations.invoke(op) 
開發者ID:jpush,項目名稱:jbox,代碼行數:28,代碼來源:ops.py

示例7: drop_index

# 需要導入模塊: from sqlalchemy.sql import func [as 別名]
# 或者: from sqlalchemy.sql.func import now [as 別名]
def drop_index(cls, operations, index_name, table_name=None, schema=None):
        """Issue a "drop index" instruction using the current
        migration context.

        e.g.::

            drop_index("accounts")

        :param index_name: name of the index.
        :param table_name: name of the owning table.  Some
         backends such as Microsoft SQL Server require this.
        :param schema: Optional schema name to operate within.  To control
         quoting of the schema outside of the default behavior, use
         the SQLAlchemy construct
         :class:`~sqlalchemy.sql.elements.quoted_name`.

         .. versionadded:: 0.7.0 'schema' can now accept a
            :class:`~sqlalchemy.sql.elements.quoted_name` construct.

        .. versionchanged:: 0.8.0 The following positional argument names
           have been changed:

           * name -> index_name

        """
        op = cls(index_name, table_name=table_name, schema=schema)
        return operations.invoke(op) 
開發者ID:jpush,項目名稱:jbox,代碼行數:29,代碼來源:ops.py

示例8: drop_constraint

# 需要導入模塊: from sqlalchemy.sql import func [as 別名]
# 或者: from sqlalchemy.sql.func import now [as 別名]
def drop_constraint(
        cls, operations, constraint_name, table_name, type_=None, schema=None
    ):
        r"""Drop a constraint of the given name, typically via DROP CONSTRAINT.

        :param constraint_name: name of the constraint.
        :param table_name: table name.
        :param type\_: optional, required on MySQL.  can be
         'foreignkey', 'primary', 'unique', or 'check'.
        :param schema: Optional schema name to operate within.  To control
         quoting of the schema outside of the default behavior, use
         the SQLAlchemy construct
         :class:`~sqlalchemy.sql.elements.quoted_name`.

         .. versionadded:: 0.7.0 'schema' can now accept a
            :class:`~sqlalchemy.sql.elements.quoted_name` construct.

        .. versionchanged:: 0.8.0 The following positional argument names
           have been changed:

           * name -> constraint_name

        """

        op = cls(constraint_name, table_name, type_=type_, schema=schema)
        return operations.invoke(op) 
開發者ID:sqlalchemy,項目名稱:alembic,代碼行數:28,代碼來源:ops.py

示例9: drop_index

# 需要導入模塊: from sqlalchemy.sql import func [as 別名]
# 或者: from sqlalchemy.sql.func import now [as 別名]
def drop_index(
        cls, operations, index_name, table_name=None, schema=None, **kw
    ):
        r"""Issue a "drop index" instruction using the current
        migration context.

        e.g.::

            drop_index("accounts")

        :param index_name: name of the index.
        :param table_name: name of the owning table.  Some
         backends such as Microsoft SQL Server require this.
        :param schema: Optional schema name to operate within.  To control
         quoting of the schema outside of the default behavior, use
         the SQLAlchemy construct
         :class:`~sqlalchemy.sql.elements.quoted_name`.

         .. versionadded:: 0.7.0 'schema' can now accept a
            :class:`~sqlalchemy.sql.elements.quoted_name` construct.

        :param \**kw: Additional keyword arguments not mentioned above are
            dialect specific, and passed in the form
            ``<dialectname>_<argname>``.
            See the documentation regarding an individual dialect at
            :ref:`dialect_toplevel` for detail on documented arguments.

            .. versionadded:: 0.9.5 Support for dialect-specific keyword
               arguments for DROP INDEX

        .. versionchanged:: 0.8.0 The following positional argument names
           have been changed:

           * name -> index_name

        """
        op = cls(index_name, table_name=table_name, schema=schema, **kw)
        return operations.invoke(op) 
開發者ID:sqlalchemy,項目名稱:alembic,代碼行數:40,代碼來源:ops.py

示例10: set_url

# 需要導入模塊: from sqlalchemy.sql import func [as 別名]
# 或者: from sqlalchemy.sql.func import now [as 別名]
def set_url(self, id, url):
        ks = {"update_time": datetime.now(), "check": True, "url": url}
        self.get_session().query(self._model).filter_by(id=id).update(ks)
# DB End
############################################################################### 
開發者ID:xgfone,項目名稱:snippet,代碼行數:7,代碼來源:check_music.py

示例11: date_created

# 需要導入模塊: from sqlalchemy.sql import func [as 別名]
# 或者: from sqlalchemy.sql.func import now [as 別名]
def date_created(cls):
        return db.Column(
            db.TIMESTAMP(timezone=True),
            default=timezone.now,
            server_default=func.now(),
            nullable=False,
        )


# https://bitbucket.org/zzzeek/sqlalchemy/wiki/UsageRecipes/PreFilteredQuery 
開發者ID:getsentry,項目名稱:zeus,代碼行數:12,代碼來源:mixins.py

示例12: init

# 需要導入模塊: from sqlalchemy.sql import func [as 別名]
# 或者: from sqlalchemy.sql.func import now [as 別名]
def init(self, auto_create=True):

        # TODO handle if user does not pass in table sqlite://path.db
        uri_splt = self.uri.split(":")
        engine_uri = ":".join(uri_splt[:-1])
        table_name = uri_splt[-1]

        metadata = MetaData()
        postref_table = Table(table_name, metadata,
                              Column('id', Integer, primary_key=True),
                              Column('created_at', DateTime, default=func.now()),
                              Column('updated_at', DateTime, default=func.now(), onupdate=func.current_timestamp()),
                              Column('uuid', String(512)),
                              Column('path', String(512)),
                              Column('revision', Integer, default=0),
                              Column('status', Integer, default=self.PostStatus.DRAFT.value),
                              Column('ref', String(512)),
                              Column('data', LargeBinary))
        self.engine = create_engine(engine_uri, pool_recycle=3600)
        self.session = scoped_session(sessionmaker(bind=self.engine))
        if auto_create:
            postref_table.create(self.engine, checkfirst=True)

        class PostRef(object):
            pass
        mapper(PostRef, postref_table)
        self.PostRef = PostRef

    # ------------- Repository actions / state ------------------------------------ 
開發者ID:airbnb,項目名稱:knowledge-repo,代碼行數:31,代碼來源:dbrepository.py

示例13: save_json

# 需要導入模塊: from sqlalchemy.sql import func [as 別名]
# 或者: from sqlalchemy.sql.func import now [as 別名]
def save_json(self, key, data):
        data = json.dumps(data, separators=(",", ":"))
        updated = func.now()
        try:
            s = self.items.insert().values(key=key, data=data, updated=updated)
            s.execute()
        except IntegrityError:
            s = (
                self.items.update()
                .where(self.items.c.key == key)
                .values(key=key, data=data, updated=updated)
            )
            s.execute() 
開發者ID:openeemeter,項目名稱:eeweather,代碼行數:15,代碼來源:cache.py

示例14: statistics

# 需要導入模塊: from sqlalchemy.sql import func [as 別名]
# 或者: from sqlalchemy.sql.func import now [as 別名]
def statistics():
    """
    Show global and per-package statistics about build times etc.
    Uses materialized views that are refreshed by backend's polling.
    """
    now = db.query(func.now()).scalar()
    scalar_stats = db.query(ScalarStats).one()
    resource_query = db.query(ResourceConsumptionStats)\
        .order_by(ResourceConsumptionStats.time.desc().nullslast())\
        .paginate(20)
    return render_template("stats.html", now=now, stats=scalar_stats,
                           packages=resource_query.items,
                           page=resource_query) 
開發者ID:fedora-infra,項目名稱:koschei,代碼行數:15,代碼來源:views.py

示例15: drop_index

# 需要導入模塊: from sqlalchemy.sql import func [as 別名]
# 或者: from sqlalchemy.sql.func import now [as 別名]
def drop_index(cls, operations, index_name,
                   table_name=None, schema=None, **kw):
        r"""Issue a "drop index" instruction using the current
        migration context.

        e.g.::

            drop_index("accounts")

        :param index_name: name of the index.
        :param table_name: name of the owning table.  Some
         backends such as Microsoft SQL Server require this.
        :param schema: Optional schema name to operate within.  To control
         quoting of the schema outside of the default behavior, use
         the SQLAlchemy construct
         :class:`~sqlalchemy.sql.elements.quoted_name`.

         .. versionadded:: 0.7.0 'schema' can now accept a
            :class:`~sqlalchemy.sql.elements.quoted_name` construct.

        :param \**kw: Additional keyword arguments not mentioned above are
            dialect specific, and passed in the form
            ``<dialectname>_<argname>``.
            See the documentation regarding an individual dialect at
            :ref:`dialect_toplevel` for detail on documented arguments.

            .. versionadded:: 0.9.5 Support for dialect-specific keyword
               arguments for DROP INDEX

        .. versionchanged:: 0.8.0 The following positional argument names
           have been changed:

           * name -> index_name

        """
        op = cls(index_name, table_name=table_name, schema=schema, **kw)
        return operations.invoke(op) 
開發者ID:bkerler,項目名稱:android_universal,代碼行數:39,代碼來源:ops.py


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