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


Python pysqlite.dialect方法代码示例

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


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

示例1: test_no_convert_unicode

# 需要导入模块: from sqlalchemy.dialects.sqlite import pysqlite [as 别名]
# 或者: from sqlalchemy.dialects.sqlite.pysqlite import dialect [as 别名]
def test_no_convert_unicode(self):
        """test no utf-8 encoding occurs"""

        dialect = sqlite.dialect()
        for t in (
            String(),
            sqltypes.CHAR(),
            sqltypes.Unicode(),
            sqltypes.UnicodeText(),
            String(),
            sqltypes.CHAR(),
            sqltypes.Unicode(),
            sqltypes.UnicodeText(),
        ):
            bindproc = t.dialect_impl(dialect).bind_processor(dialect)
            assert not bindproc or isinstance(
                bindproc(util.u("some string")), util.text_type
            ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:20,代码来源:test_sqlite.py

示例2: test_in_tuple

# 需要导入模块: from sqlalchemy.dialects.sqlite import pysqlite [as 别名]
# 或者: from sqlalchemy.dialects.sqlite.pysqlite import dialect [as 别名]
def test_in_tuple(self):
        compiled = (
            tuple_(column("q"), column("p"))
            .in_([(1, 2), (3, 4)])
            .compile(dialect=sqlite.dialect())
        )
        eq_(str(compiled), "(q, p) IN ([POSTCOMPILE_param_1])")
        eq_(
            compiled._literal_execute_expanding_parameter(
                "param_1",
                compiled.binds["param_1"],
                compiled.binds["param_1"].value,
            ),
            (
                [
                    ("param_1_1_1", 1),
                    ("param_1_1_2", 2),
                    ("param_1_2_1", 3),
                    ("param_1_2_2", 4),
                ],
                "VALUES (?, ?), (?, ?)",
            ),
        ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:25,代码来源:test_sqlite.py

示例3: test_on_conflict_clause_unique_constraint

# 需要导入模块: from sqlalchemy.dialects.sqlite import pysqlite [as 别名]
# 或者: from sqlalchemy.dialects.sqlite.pysqlite import dialect [as 别名]
def test_on_conflict_clause_unique_constraint(self):

        meta = MetaData()
        t = Table(
            "n",
            meta,
            Column("id", Integer),
            Column("x", String(30)),
            UniqueConstraint("id", "x", sqlite_on_conflict="FAIL"),
        )

        self.assert_compile(
            CreateTable(t),
            "CREATE TABLE n (id INTEGER, x VARCHAR(30), "
            "UNIQUE (id, x) ON CONFLICT FAIL)",
            dialect=sqlite.dialect(),
        ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:19,代码来源:test_sqlite.py

示例4: test_on_conflict_clause_primary_key

# 需要导入模块: from sqlalchemy.dialects.sqlite import pysqlite [as 别名]
# 或者: from sqlalchemy.dialects.sqlite.pysqlite import dialect [as 别名]
def test_on_conflict_clause_primary_key(self):

        meta = MetaData()
        t = Table(
            "n",
            meta,
            Column(
                "id",
                Integer,
                primary_key=True,
                sqlite_on_conflict_primary_key="FAIL",
            ),
            sqlite_autoincrement=True,
        )

        self.assert_compile(
            CreateTable(t),
            "CREATE TABLE n (id INTEGER NOT NULL "
            "PRIMARY KEY ON CONFLICT FAIL AUTOINCREMENT)",
            dialect=sqlite.dialect(),
        ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:23,代码来源:test_sqlite.py

示例5: test_on_conflict_clause_primary_key_constraint_from_column

# 需要导入模块: from sqlalchemy.dialects.sqlite import pysqlite [as 别名]
# 或者: from sqlalchemy.dialects.sqlite.pysqlite import dialect [as 别名]
def test_on_conflict_clause_primary_key_constraint_from_column(self):

        meta = MetaData()
        t = Table(
            "n",
            meta,
            Column(
                "x",
                String(30),
                sqlite_on_conflict_primary_key="FAIL",
                primary_key=True,
            ),
        )

        self.assert_compile(
            CreateTable(t),
            "CREATE TABLE n (x VARCHAR(30) NOT NULL, "
            "PRIMARY KEY (x) ON CONFLICT FAIL)",
            dialect=sqlite.dialect(),
        ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:22,代码来源:test_sqlite.py

示例6: test_on_conflict_clause_check_constraint

# 需要导入模块: from sqlalchemy.dialects.sqlite import pysqlite [as 别名]
# 或者: from sqlalchemy.dialects.sqlite.pysqlite import dialect [as 别名]
def test_on_conflict_clause_check_constraint(self):

        meta = MetaData()
        t = Table(
            "n",
            meta,
            Column("id", Integer),
            Column("x", Integer),
            CheckConstraint("id > x", sqlite_on_conflict="FAIL"),
        )

        self.assert_compile(
            CreateTable(t),
            "CREATE TABLE n (id INTEGER, x INTEGER, "
            "CHECK (id > x) ON CONFLICT FAIL)",
            dialect=sqlite.dialect(),
        ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:19,代码来源:test_sqlite.py

示例7: test_on_conflict_clause_primary_key_constraint

# 需要导入模块: from sqlalchemy.dialects.sqlite import pysqlite [as 别名]
# 或者: from sqlalchemy.dialects.sqlite.pysqlite import dialect [as 别名]
def test_on_conflict_clause_primary_key_constraint(self):

        meta = MetaData()
        t = Table(
            "n",
            meta,
            Column("id", Integer),
            Column("x", String(30)),
            PrimaryKeyConstraint("id", "x", sqlite_on_conflict="FAIL"),
        )

        self.assert_compile(
            CreateTable(t),
            "CREATE TABLE n ("
            "id INTEGER NOT NULL, "
            "x VARCHAR(30) NOT NULL, "
            "PRIMARY KEY (id, x) ON CONFLICT FAIL)",
            dialect=sqlite.dialect(),
        ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:21,代码来源:test_sqlite.py

示例8: test_sqlite_autoincrement_constraint

# 需要导入模块: from sqlalchemy.dialects.sqlite import pysqlite [as 别名]
# 或者: from sqlalchemy.dialects.sqlite.pysqlite import dialect [as 别名]
def test_sqlite_autoincrement_constraint(self):
        table = Table(
            "autoinctable",
            MetaData(),
            Column("id", Integer, primary_key=True),
            Column("x", Integer, default=None),
            UniqueConstraint("x"),
            sqlite_autoincrement=True,
        )
        self.assert_compile(
            schema.CreateTable(table),
            "CREATE TABLE autoinctable (id INTEGER NOT "
            "NULL PRIMARY KEY AUTOINCREMENT, x "
            "INTEGER, UNIQUE (x))",
            dialect=sqlite.dialect(),
        ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:18,代码来源:test_sqlite.py

示例9: test_native_datetime

# 需要导入模块: from sqlalchemy.dialects.sqlite import pysqlite [as 别名]
# 或者: from sqlalchemy.dialects.sqlite.pysqlite import dialect [as 别名]
def test_native_datetime(self):
        dbapi = testing.db.dialect.dbapi
        connect_args = {
            "detect_types": dbapi.PARSE_DECLTYPES | dbapi.PARSE_COLNAMES
        }
        engine = engines.testing_engine(
            options={"connect_args": connect_args, "native_datetime": True}
        )
        t = Table(
            "datetest",
            MetaData(),
            Column("id", Integer, primary_key=True),
            Column("d1", Date),
            Column("d2", sqltypes.TIMESTAMP),
        )
        t.create(engine)
        try:
            with engine.begin() as conn:
                conn.execute(
                    t.insert(),
                    {
                        "d1": datetime.date(2010, 5, 10),
                        "d2": datetime.datetime(2010, 5, 10, 12, 15, 25),
                    },
                )
                row = conn.execute(t.select()).first()
                eq_(
                    row,
                    (
                        1,
                        datetime.date(2010, 5, 10),
                        datetime.datetime(2010, 5, 10, 12, 15, 25),
                    ),
                )
                r = conn.execute(func.current_date()).scalar()
                assert isinstance(r, util.string_types)
        finally:
            t.drop(engine)
            engine.dispose() 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:41,代码来源:test_sqlite.py

示例10: test_deprecated_serializer_args

# 需要导入模块: from sqlalchemy.dialects.sqlite import pysqlite [as 别名]
# 或者: from sqlalchemy.dialects.sqlite.pysqlite import dialect [as 别名]
def test_deprecated_serializer_args(self):
        sqlite_json = Table(
            "json_test", self.metadata, Column("foo", sqlite.JSON)
        )
        data_element = {"foo": "bar"}

        js = mock.Mock(side_effect=json.dumps)
        jd = mock.Mock(side_effect=json.loads)

        with testing.expect_deprecated(
            "The _json_deserializer argument to the SQLite "
            "dialect has been renamed",
            "The _json_serializer argument to the SQLite "
            "dialect has been renamed",
        ):
            engine = engines.testing_engine(
                options=dict(_json_serializer=js, _json_deserializer=jd)
            )
        self.metadata.create_all(engine)

        with engine.begin() as conn:
            conn.execute(sqlite_json.insert(), {"foo": data_element})

            row = conn.execute(select([sqlite_json.c.foo])).first()

            eq_(row, (data_element,))
            eq_(js.mock_calls, [mock.call(data_element)])
            eq_(jd.mock_calls, [mock.call(json.dumps(data_element))]) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:30,代码来源:test_sqlite.py

示例11: test_old_style_default

# 需要导入模块: from sqlalchemy.dialects.sqlite import pysqlite [as 别名]
# 或者: from sqlalchemy.dialects.sqlite.pysqlite import dialect [as 别名]
def test_old_style_default(self):
        """test non-quoted integer value on older sqlite pragma"""

        dialect = sqlite.dialect()
        info = dialect._get_column_info(
            "foo", "INTEGER", False, 3, False, False, False, None
        )
        eq_(info["default"], "3") 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:10,代码来源:test_sqlite.py

示例12: test_3_7_16_warning

# 需要导入模块: from sqlalchemy.dialects.sqlite import pysqlite [as 别名]
# 或者: from sqlalchemy.dialects.sqlite.pysqlite import dialect [as 别名]
def test_3_7_16_warning(self):
        with expect_warnings(
            r"SQLite version \(3, 2, 8\) is older than 3.7.16, and "
            "will not support right nested joins"
        ):
            sqlite.dialect(
                dbapi=mock.Mock(
                    version_info=(2, 6, 0), sqlite_version_info=(3, 2, 8)
                )
            ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:12,代码来源:test_sqlite.py

示例13: test_connect_args

# 需要导入模块: from sqlalchemy.dialects.sqlite import pysqlite [as 别名]
# 或者: from sqlalchemy.dialects.sqlite.pysqlite import dialect [as 别名]
def test_connect_args(self, url, expected):
        """test create_connect_args scenarios including support for uri=True"""

        d = pysqlite_dialect.dialect()
        url = make_url(url)
        eq_(d.create_connect_args(url), expected) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:8,代码来源:test_sqlite.py

示例14: test_create_partial_index

# 需要导入模块: from sqlalchemy.dialects.sqlite import pysqlite [as 别名]
# 或者: from sqlalchemy.dialects.sqlite.pysqlite import dialect [as 别名]
def test_create_partial_index(self):
        m = MetaData()
        tbl = Table("testtbl", m, Column("data", Integer))
        idx = Index(
            "test_idx1",
            tbl.c.data,
            sqlite_where=and_(tbl.c.data > 5, tbl.c.data < 10),
        )

        # test quoting and all that

        idx2 = Index(
            "test_idx2",
            tbl.c.data,
            sqlite_where=and_(tbl.c.data > "a", tbl.c.data < "b's"),
        )
        self.assert_compile(
            schema.CreateIndex(idx),
            "CREATE INDEX test_idx1 ON testtbl (data) "
            "WHERE data > 5 AND data < 10",
            dialect=sqlite.dialect(),
        )
        self.assert_compile(
            schema.CreateIndex(idx2),
            "CREATE INDEX test_idx2 ON testtbl (data) "
            "WHERE data > 'a' AND data < 'b''s'",
            dialect=sqlite.dialect(),
        ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:30,代码来源:test_sqlite.py

示例15: test_no_autoinc_on_composite_pk

# 需要导入模块: from sqlalchemy.dialects.sqlite import pysqlite [as 别名]
# 或者: from sqlalchemy.dialects.sqlite.pysqlite import dialect [as 别名]
def test_no_autoinc_on_composite_pk(self):
        m = MetaData()
        t = Table(
            "t",
            m,
            Column("x", Integer, primary_key=True, autoincrement=True),
            Column("y", Integer, primary_key=True),
        )
        assert_raises_message(
            exc.CompileError,
            "SQLite does not support autoincrement for composite",
            CreateTable(t).compile,
            dialect=sqlite.dialect(),
        ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:16,代码来源:test_sqlite.py


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