微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Python psycopg2 模块-STRING 实例源码

Python psycopg2 模块,STRING 实例源码

我们从Python开源项目中,提取了以下5代码示例,用于说明如何使用psycopg2.STRING

项目:Scrum    作者:prakharchoudhary    | 项目源码 | 文件源码
def register_type_handlers(connection, **kwargs):
    if connection.vendor != 'postgresql':
        return

    try:
        if six.PY2:
            register_hstore(connection.connection, globally=True, unicode=True)
        else:
            register_hstore(connection.connection, globally=True)
    except ProgrammingError:
        # Hstore is not available on the database.
        #
        # If someone tries to create an hstore field it will error there.
        # This is necessary as someone may be using Psql without extensions
        # installed but be using other features of contrib.postgres.
        #
        # This is also needed in order to create the connection in order to
        # install the hstore extension.
        pass

    try:
        with connection.cursor() as cursor:
            # Retrieve oids of citext arrays.
            cursor.execute("SELECT typarray FROM pg_type WHERE typname = 'citext'")
            oids = tuple(row[0] for row in cursor)
        array_type = psycopg2.extensions.new_array_type(oids, 'citext[]', psycopg2.STRING)
        psycopg2.extensions.register_type(array_type, None)
    except ProgrammingError:
        # citext is not available on the database.
        #
        # The same comments in the except block of the above call to
        # register_hstore() also apply here.
        pass
项目:django    作者:alexsukhrin    | 项目源码 | 文件源码
def register_type_handlers(connection, None)
    except ProgrammingError:
        # citext is not available on the database.
        #
        # The same comments in the except block of the above call to
        # register_hstore() also apply here.
        pass
项目:liberator    作者:libscie    | 项目源码 | 文件源码
def register_type_handlers(connection, None)
    except ProgrammingError:
        # citext is not available on the database.
        #
        # The same comments in the except block of the above call to
        # register_hstore() also apply here.
        pass
项目:django-rtc    作者:scifiswapnil    | 项目源码 | 文件源码
def register_type_handlers(connection, None)
    except ProgrammingError:
        # citext is not available on the database.
        #
        # The same comments in the except block of the above call to
        # register_hstore() also apply here.
        pass
项目:LatinSounds_AppEnviaMail    作者:G3ek-aR    | 项目源码 | 文件源码
def register_type_handlers(connection, None)
    except ProgrammingError:
        # citext is not available on the database.
        #
        # The same comments in the except block of the above call to
        # register_hstore() also apply here.
        pass

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐