当前位置: 首页>>代码示例>>Python>>正文


Python postgresql.INTEGER属性代码示例

本文整理汇总了Python中sqlalchemy.dialects.postgresql.INTEGER属性的典型用法代码示例。如果您正苦于以下问题:Python postgresql.INTEGER属性的具体用法?Python postgresql.INTEGER怎么用?Python postgresql.INTEGER使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在sqlalchemy.dialects.postgresql的用法示例。


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

示例1: autogen_column_reflect

# 需要导入模块: from sqlalchemy.dialects import postgresql [as 别名]
# 或者: from sqlalchemy.dialects.postgresql import INTEGER [as 别名]
def autogen_column_reflect(self, inspector, table, column_info):
        if column_info.get('default') and \
                isinstance(column_info['type'], (INTEGER, BIGINT)):
            seq_match = re.match(
                r"nextval\('(.+?)'::regclass\)",
                column_info['default'])
            if seq_match:
                info = inspector.bind.execute(text(
                    "select c.relname, a.attname "
                    "from pg_class as c join pg_depend d on d.objid=c.oid and "
                    "d.classid='pg_class'::regclass and "
                    "d.refclassid='pg_class'::regclass "
                    "join pg_class t on t.oid=d.refobjid "
                    "join pg_attribute a on a.attrelid=t.oid and "
                    "a.attnum=d.refobjsubid "
                    "where c.relkind='S' and c.relname=:seqname"
                ), seqname=seq_match.group(1)).first()
                if info:
                    seqname, colname = info
                    if colname == column_info['name']:
                        log.info(
                            "Detected sequence named '%s' as "
                            "owned by integer column '%s(%s)', "
                            "assuming SERIAL and omitting",
                            seqname, table.name, colname)
                        # sequence, and the owner is this column,
                        # its a SERIAL - whack it!
                        del column_info['default'] 
开发者ID:jpush,项目名称:jbox,代码行数:30,代码来源:postgresql.py

示例2: autogen_column_reflect

# 需要导入模块: from sqlalchemy.dialects import postgresql [as 别名]
# 或者: from sqlalchemy.dialects.postgresql import INTEGER [as 别名]
def autogen_column_reflect(self, inspector, table, column_info):
        if column_info.get("default") and isinstance(
            column_info["type"], (INTEGER, BIGINT)
        ):
            seq_match = re.match(
                r"nextval\('(.+?)'::regclass\)", column_info["default"]
            )
            if seq_match:
                info = sqla_compat._exec_on_inspector(
                    inspector,
                    text(
                        "select c.relname, a.attname "
                        "from pg_class as c join "
                        "pg_depend d on d.objid=c.oid and "
                        "d.classid='pg_class'::regclass and "
                        "d.refclassid='pg_class'::regclass "
                        "join pg_class t on t.oid=d.refobjid "
                        "join pg_attribute a on a.attrelid=t.oid and "
                        "a.attnum=d.refobjsubid "
                        "where c.relkind='S' and c.relname=:seqname"
                    ),
                    seqname=seq_match.group(1),
                ).first()
                if info:
                    seqname, colname = info
                    if colname == column_info["name"]:
                        log.info(
                            "Detected sequence named '%s' as "
                            "owned by integer column '%s(%s)', "
                            "assuming SERIAL and omitting",
                            seqname,
                            table.name,
                            colname,
                        )
                        # sequence, and the owner is this column,
                        # its a SERIAL - whack it!
                        del column_info["default"] 
开发者ID:sqlalchemy,项目名称:alembic,代码行数:39,代码来源:postgresql.py

示例3: setup_class

# 需要导入模块: from sqlalchemy.dialects import postgresql [as 别名]
# 或者: from sqlalchemy.dialects.postgresql import INTEGER [as 别名]
def setup_class(cls):
        con = testing.db.connect()
        for ddl in [
            'CREATE SCHEMA "SomeSchema"',
            "CREATE DOMAIN testdomain INTEGER NOT NULL DEFAULT 42",
            "CREATE DOMAIN test_schema.testdomain INTEGER DEFAULT 0",
            "CREATE TYPE testtype AS ENUM ('test')",
            "CREATE DOMAIN enumdomain AS testtype",
            "CREATE DOMAIN arraydomain AS INTEGER[]",
            'CREATE DOMAIN "SomeSchema"."Quoted.Domain" INTEGER DEFAULT 0',
        ]:
            try:
                con.exec_driver_sql(ddl)
            except exc.DBAPIError as e:
                if "already exists" not in str(e):
                    raise e
        con.exec_driver_sql(
            "CREATE TABLE testtable (question integer, answer " "testdomain)"
        )
        con.exec_driver_sql(
            "CREATE TABLE test_schema.testtable(question "
            "integer, answer test_schema.testdomain, anything "
            "integer)"
        )
        con.exec_driver_sql(
            "CREATE TABLE crosschema (question integer, answer "
            "test_schema.testdomain)"
        )

        con.exec_driver_sql(
            "CREATE TABLE enum_test (id integer, data enumdomain)"
        )

        con.exec_driver_sql(
            "CREATE TABLE array_test (id integer, data arraydomain)"
        )

        con.exec_driver_sql(
            "CREATE TABLE quote_test "
            '(id integer, data "SomeSchema"."Quoted.Domain")'
        ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:43,代码来源:test_reflection.py

示例4: test_array_domain_is_reflected

# 需要导入模块: from sqlalchemy.dialects import postgresql [as 别名]
# 或者: from sqlalchemy.dialects.postgresql import INTEGER [as 别名]
def test_array_domain_is_reflected(self):
        metadata = MetaData(testing.db)
        table = Table("array_test", metadata, autoload=True)
        eq_(table.c.data.type.__class__, ARRAY)
        eq_(table.c.data.type.item_type.__class__, INTEGER) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:7,代码来源:test_reflection.py

示例5: test_quoted_remote_schema_domain_is_reflected

# 需要导入模块: from sqlalchemy.dialects import postgresql [as 别名]
# 或者: from sqlalchemy.dialects.postgresql import INTEGER [as 别名]
def test_quoted_remote_schema_domain_is_reflected(self):
        metadata = MetaData(testing.db)
        table = Table("quote_test", metadata, autoload=True)
        eq_(table.c.data.type.__class__, INTEGER) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:6,代码来源:test_reflection.py


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