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


Python base.dialect方法代码示例

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


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

示例1: test_no_clobs_for_string_params

# 需要导入模块: from sqlalchemy.dialects.oracle import base [as 别名]
# 或者: from sqlalchemy.dialects.oracle.base import dialect [as 别名]
def test_no_clobs_for_string_params(self):
        """test that simple string params get a DBAPI type of
        VARCHAR, not CLOB. This is to prevent setinputsizes
        from setting up cx_oracle.CLOBs on
        string-based bind params [ticket:793]."""

        class FakeDBAPI(object):
            def __getattr__(self, attr):
                return attr

        dialect = oracle.OracleDialect()
        dbapi = FakeDBAPI()

        b = bindparam("foo", "hello world!")
        eq_(b.type.dialect_impl(dialect).get_dbapi_type(dbapi), "STRING")

        b = bindparam("foo", "hello world!")
        eq_(b.type.dialect_impl(dialect).get_dbapi_type(dbapi), "STRING") 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:20,代码来源:test_types.py

示例2: test_reflect_unicode_no_nvarchar

# 需要导入模块: from sqlalchemy.dialects.oracle import base [as 别名]
# 或者: from sqlalchemy.dialects.oracle.base import dialect [as 别名]
def test_reflect_unicode_no_nvarchar(self):
        metadata = self.metadata
        Table("tnv", metadata, Column("data", sqltypes.Unicode(255)))
        metadata.create_all()
        m2 = MetaData(testing.db)
        t2 = Table("tnv", m2, autoload=True)
        assert isinstance(t2.c.data.type, sqltypes.VARCHAR)

        if testing.against("oracle+cx_oracle"):
            assert isinstance(
                t2.c.data.type.dialect_impl(testing.db.dialect),
                cx_oracle._OracleString,
            )

        data = u("m’a réveillé.")
        t2.insert().execute(data=data)
        res = t2.select().execute().first()["data"]
        eq_(res, data)
        assert isinstance(res, util.text_type) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:21,代码来源:test_types.py

示例3: test_were_getting_a_comma

# 需要导入模块: from sqlalchemy.dialects.oracle import base [as 别名]
# 或者: from sqlalchemy.dialects.oracle.base import dialect [as 别名]
def test_were_getting_a_comma(self):
        connection = self.engine.pool._creator()
        cursor = connection.cursor()
        try:
            cx_Oracle = self.engine.dialect.dbapi

            def output_type_handler(
                cursor, name, defaultType, size, precision, scale
            ):
                return cursor.var(
                    cx_Oracle.STRING, 255, arraysize=cursor.arraysize
                )

            cursor.outputtypehandler = output_type_handler
            cursor.execute("SELECT 1.1 FROM DUAL")
            row = cursor.fetchone()
            eq_(row[0], "1,1")
        finally:
            cursor.close()
            connection.close() 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:22,代码来源:test_types.py

示例4: test_older_cx_oracle_warning

# 需要导入模块: from sqlalchemy.dialects.oracle import base [as 别名]
# 或者: from sqlalchemy.dialects.oracle.base import dialect [as 别名]
def test_older_cx_oracle_warning(self, cx_Oracle, cx_oracle_type):
        cx_Oracle.version = "6.3"

        ignore_dialect = cx_oracle.dialect(
            dbapi=cx_Oracle, encoding_errors="ignore"
        )
        ignore_outputhandler = (
            ignore_dialect._generate_connection_outputtype_handler()
        )

        cursor = mock.Mock()

        with testing.expect_warnings(
            r"cx_oracle version \(6, 3\) does not support encodingErrors"
        ):
            ignore_outputhandler(
                cursor, "foo", cx_oracle_type, None, None, None
            ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:20,代码来源:test_dialect.py

示例5: test_encoding_errors_cx_oracle_py3k

# 需要导入模块: from sqlalchemy.dialects.oracle import base [as 别名]
# 或者: from sqlalchemy.dialects.oracle.base import dialect [as 别名]
def test_encoding_errors_cx_oracle_py3k(
        self, cx_Oracle, cx_oracle_type,
    ):
        ignore_dialect = cx_oracle.dialect(
            dbapi=cx_Oracle, encoding_errors="ignore"
        )

        ignore_outputhandler = (
            ignore_dialect._generate_connection_outputtype_handler()
        )

        cursor = mock.Mock()
        ignore_outputhandler(cursor, "foo", cx_oracle_type, None, None, None)

        eq_(
            cursor.mock_calls,
            [
                mock.call.var(
                    mock.ANY, None, cursor.arraysize, encodingErrors="ignore",
                )
            ],
        ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:24,代码来源:test_dialect.py

示例6: test_no_encoding_errors_cx_oracle_py3k

# 需要导入模块: from sqlalchemy.dialects.oracle import base [as 别名]
# 或者: from sqlalchemy.dialects.oracle.base import dialect [as 别名]
def test_no_encoding_errors_cx_oracle_py3k(
        self, cx_Oracle, cx_oracle_type,
    ):
        plain_dialect = cx_oracle.dialect(dbapi=cx_Oracle)

        plain_outputhandler = (
            plain_dialect._generate_connection_outputtype_handler()
        )

        cursor = mock.Mock()
        plain_outputhandler(cursor, "foo", cx_oracle_type, None, None, None)

        eq_(
            cursor.mock_calls,
            [mock.call.var(mock.ANY, None, cursor.arraysize)],
        ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:18,代码来源:test_dialect.py

示例7: test_ora8_flags

# 需要导入模块: from sqlalchemy.dialects.oracle import base [as 别名]
# 或者: from sqlalchemy.dialects.oracle.base import dialect [as 别名]
def test_ora8_flags(self):
        dialect = self._dialect((8, 2, 5))

        # before connect, assume modern DB
        assert dialect._supports_char_length
        assert dialect.use_ansi
        assert not dialect._use_nchar_for_unicode

        dialect.initialize(Mock())
        assert not dialect.implicit_returning
        assert not dialect._supports_char_length
        assert not dialect.use_ansi
        self.assert_compile(String(50), "VARCHAR2(50)", dialect=dialect)
        self.assert_compile(Unicode(50), "VARCHAR2(50)", dialect=dialect)
        self.assert_compile(UnicodeText(), "CLOB", dialect=dialect)

        dialect = self._dialect((8, 2, 5), implicit_returning=True)
        dialect.initialize(testing.db.connect())
        assert dialect.implicit_returning 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:21,代码来源:test_dialect.py

示例8: test_max_ident_122

# 需要导入模块: from sqlalchemy.dialects.oracle import base [as 别名]
# 或者: from sqlalchemy.dialects.oracle.base import dialect [as 别名]
def test_max_ident_122(self):
        dialect = self._dialect((12, 2, 0))

        conn = mock.Mock(
            exec_driver_sql=mock.Mock(
                return_value=mock.Mock(scalar=lambda: "12.2.0")
            )
        )
        dialect.initialize(conn)
        eq_(dialect.server_version_info, (12, 2, 0))
        eq_(
            dialect._get_effective_compat_server_version_info(conn), (12, 2, 0)
        )
        eq_(
            dialect.max_identifier_length,
            oracle.OracleDialect.max_identifier_length,
        ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:19,代码来源:test_dialect.py

示例9: test_max_ident_122_11compat_vparam_raises

# 需要导入模块: from sqlalchemy.dialects.oracle import base [as 别名]
# 或者: from sqlalchemy.dialects.oracle.base import dialect [as 别名]
def test_max_ident_122_11compat_vparam_raises(self):
        dialect = self._dialect((12, 2, 0))

        def c122():
            raise exc.DBAPIError(
                "statement", None, "no such table", None, None
            )

        conn = mock.Mock(
            exec_driver_sql=mock.Mock(return_value=mock.Mock(scalar=c122))
        )
        dialect.initialize(conn)
        eq_(dialect.server_version_info, (12, 2, 0))
        eq_(
            dialect._get_effective_compat_server_version_info(conn), (12, 2, 0)
        )
        eq_(
            dialect.max_identifier_length,
            oracle.OracleDialect.max_identifier_length,
        ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:22,代码来源:test_dialect.py

示例10: test_max_ident_122_11compat_vparam_cant_parse

# 需要导入模块: from sqlalchemy.dialects.oracle import base [as 别名]
# 或者: from sqlalchemy.dialects.oracle.base import dialect [as 别名]
def test_max_ident_122_11compat_vparam_cant_parse(self):
        dialect = self._dialect((12, 2, 0))

        def c122():
            return "12.thisiscrap.0"

        conn = mock.Mock(
            exec_driver_sql=mock.Mock(return_value=mock.Mock(scalar=c122))
        )
        dialect.initialize(conn)
        eq_(dialect.server_version_info, (12, 2, 0))
        eq_(
            dialect._get_effective_compat_server_version_info(conn), (12, 2, 0)
        )
        eq_(
            dialect.max_identifier_length,
            oracle.OracleDialect.max_identifier_length,
        ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:20,代码来源:test_dialect.py

示例11: test_limit_one

# 需要导入模块: from sqlalchemy.dialects.oracle import base [as 别名]
# 或者: from sqlalchemy.dialects.oracle.base import dialect [as 别名]
def test_limit_one(self):
        t = table("sometable", column("col1"), column("col2"))
        s = select([t])
        c = s.compile(dialect=oracle.OracleDialect())
        assert t.c.col1 in set(c._create_result_map()["col1"][1])
        s = select([t]).limit(10).offset(20)
        self.assert_compile(
            s,
            "SELECT anon_1.col1, anon_1.col2 FROM "
            "(SELECT anon_2.col1 AS col1, "
            "anon_2.col2 AS col2, ROWNUM AS ora_rn FROM (SELECT "
            "sometable.col1 AS col1, sometable.col2 AS "
            "col2 FROM sometable) anon_2 WHERE ROWNUM <= "
            "[POSTCOMPILE_param_1]) anon_1 WHERE ora_rn > "
            "[POSTCOMPILE_param_2]",
            checkparams={"param_1": 30, "param_2": 20},
        )

        c = s.compile(dialect=oracle.OracleDialect())
        eq_(len(c._result_columns), 2)
        assert t.c.col1 in set(c._create_result_map()["col1"][1]) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:23,代码来源:test_compiler.py

示例12: test_limit_one_firstrows

# 需要导入模块: from sqlalchemy.dialects.oracle import base [as 别名]
# 或者: from sqlalchemy.dialects.oracle.base import dialect [as 别名]
def test_limit_one_firstrows(self):
        t = table("sometable", column("col1"), column("col2"))
        s = select([t])
        s = select([t]).limit(10).offset(20)
        self.assert_compile(
            s,
            "SELECT anon_1.col1, anon_1.col2 FROM "
            "(SELECT /*+ FIRST_ROWS([POSTCOMPILE_ora_frow_1]) */ "
            "anon_2.col1 AS col1, "
            "anon_2.col2 AS col2, ROWNUM AS ora_rn FROM (SELECT "
            "sometable.col1 AS col1, sometable.col2 AS "
            "col2 FROM sometable) anon_2 WHERE ROWNUM <= "
            "[POSTCOMPILE_param_1]) anon_1 WHERE ora_rn > "
            "[POSTCOMPILE_param_2]",
            checkparams={"ora_frow_1": 10, "param_1": 30, "param_2": 20},
            dialect=oracle.OracleDialect(optimize_limits=True),
        ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:19,代码来源:test_compiler.py

示例13: test_limit_three

# 需要导入模块: from sqlalchemy.dialects.oracle import base [as 别名]
# 或者: from sqlalchemy.dialects.oracle.base import dialect [as 别名]
def test_limit_three(self):
        t = table("sometable", column("col1"), column("col2"))

        s = select([t]).limit(10).offset(20).order_by(t.c.col2)
        self.assert_compile(
            s,
            "SELECT anon_1.col1, anon_1.col2 FROM "
            "(SELECT anon_2.col1 AS col1, "
            "anon_2.col2 AS col2, ROWNUM AS ora_rn FROM (SELECT "
            "sometable.col1 AS col1, sometable.col2 AS "
            "col2 FROM sometable ORDER BY "
            "sometable.col2) anon_2 WHERE ROWNUM <= "
            "[POSTCOMPILE_param_1]) anon_1 "
            "WHERE ora_rn > [POSTCOMPILE_param_2]",
            checkparams={"param_1": 30, "param_2": 20},
        )
        c = s.compile(dialect=oracle.OracleDialect())
        eq_(len(c._result_columns), 2)
        assert t.c.col1 in set(c._create_result_map()["col1"][1]) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:21,代码来源:test_compiler.py

示例14: test_use_binds_for_limits_disabled_one

# 需要导入模块: from sqlalchemy.dialects.oracle import base [as 别名]
# 或者: from sqlalchemy.dialects.oracle.base import dialect [as 别名]
def test_use_binds_for_limits_disabled_one(self):
        t = table("sometable", column("col1"), column("col2"))
        with testing.expect_deprecated(
            "The ``use_binds_for_limits`` Oracle dialect parameter is "
            "deprecated."
        ):
            dialect = oracle.OracleDialect(use_binds_for_limits=False)

        self.assert_compile(
            select([t]).limit(10),
            "SELECT anon_1.col1, anon_1.col2 FROM "
            "(SELECT sometable.col1 AS col1, "
            "sometable.col2 AS col2 FROM sometable) anon_1 "
            "WHERE ROWNUM <= [POSTCOMPILE_param_1]",
            dialect=dialect,
        ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:18,代码来源:test_compiler.py

示例15: test_use_binds_for_limits_disabled_two

# 需要导入模块: from sqlalchemy.dialects.oracle import base [as 别名]
# 或者: from sqlalchemy.dialects.oracle.base import dialect [as 别名]
def test_use_binds_for_limits_disabled_two(self):
        t = table("sometable", column("col1"), column("col2"))
        with testing.expect_deprecated(
            "The ``use_binds_for_limits`` Oracle dialect parameter is "
            "deprecated."
        ):
            dialect = oracle.OracleDialect(use_binds_for_limits=False)

        self.assert_compile(
            select([t]).offset(10),
            "SELECT anon_1.col1, anon_1.col2 FROM (SELECT "
            "anon_2.col1 AS col1, anon_2.col2 AS col2, ROWNUM AS ora_rn "
            "FROM (SELECT sometable.col1 AS col1, sometable.col2 AS col2 "
            "FROM sometable) anon_2) anon_1 "
            "WHERE ora_rn > [POSTCOMPILE_param_1]",
            dialect=dialect,
        ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:19,代码来源:test_compiler.py


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