db.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:nav 作者: UNINETT 项目源码 文件源码
def get_named_cursor():
    """
    This function returns a named cursor, which speeds up queries
    returning large result sets immensely by caching them on the
    server side.

    This is not yet supported by Django itself.
    """
    # This is required to populate the connection object properly
    if connection.connection is None:
        connection.cursor()

    # Prefixing the name to ensure that it starts with a letter.
    # Needed for psycopg2.2 compatibility
    name = 'nav{0}'.format(str(uuid.uuid4()).replace('-', ''))

    cursor = connection.connection.cursor(name=name)
    return cursor
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号