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


Python sqlite.dialect方法代码示例

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


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

示例1: test_query_string

# 需要导入模块: from sqlalchemy.dialects import sqlite [as 别名]
# 或者: from sqlalchemy.dialects.sqlite import dialect [as 别名]
def test_query_string(self):
        u = url.make_url("dialect://user:pass@host/db?arg1=param1&arg2=param2")
        eq_(u.query, {"arg1": "param1", "arg2": "param2"})
        eq_(str(u), "dialect://user:pass@host/db?arg1=param1&arg2=param2")

        u = url.make_url(
            "dialect://user:pass@host/db?arg1=param1&arg2=param2&arg2=param3"
        )
        eq_(u.query, {"arg1": "param1", "arg2": ["param2", "param3"]})
        eq_(
            str(u),
            "dialect://user:pass@host/db?arg1=param1&arg2=param2&arg2=param3",
        )

        test_url = "dialect://user:pass@host/db?arg1%3D=param1&arg2=param+2"
        u = url.make_url(test_url)
        eq_(u.query, {"arg1=": "param1", "arg2": "param 2"})
        eq_(str(u), test_url) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:20,代码来源:test_parseconnect.py

示例2: test_import_base_dialects

# 需要导入模块: from sqlalchemy.dialects import sqlite [as 别名]
# 或者: from sqlalchemy.dialects.sqlite import dialect [as 别名]
def test_import_base_dialects(self):
        # the globals() somehow makes it for the exec() + nose3.

        for name in (
            "mysql",
            "firebird",
            "postgresql",
            "sqlite",
            "oracle",
            "mssql",
        ):
            exec(
                "from sqlalchemy.dialects import %s\ndialect = "
                "%s.dialect()" % (name, name),
                globals(),
            )
            eq_(dialect.name, name) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:19,代码来源:test_parseconnect.py

示例3: test_custom

# 需要导入模块: from sqlalchemy.dialects import sqlite [as 别名]
# 或者: from sqlalchemy.dialects.sqlite import dialect [as 别名]
def test_custom(self):
        dbapi = MockDBAPI(
            foober=12, lala=18, hoho={"this": "dict"}, fooz="somevalue"
        )

        def connect():
            return dbapi.connect(
                foober=12, lala=18, fooz="somevalue", hoho={"this": "dict"}
            )

        # start the postgresql dialect, but put our mock DBAPI as the
        # module instead of psycopg

        e = create_engine(
            "postgresql://", creator=connect, module=dbapi, _initialize=False
        )
        e.connect() 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:19,代码来源:test_parseconnect.py

示例4: test_wrapper_hooks

# 需要导入模块: from sqlalchemy.dialects import sqlite [as 别名]
# 或者: from sqlalchemy.dialects.sqlite import dialect [as 别名]
def test_wrapper_hooks(self):
        def get_dialect_cls(url):
            url.drivername = "sqlite"
            return url.get_dialect()

        global WrapperFactory
        WrapperFactory = Mock()
        WrapperFactory.get_dialect_cls.side_effect = get_dialect_cls

        registry.register("wrapperdialect", __name__, "WrapperFactory")

        from sqlalchemy.dialects import sqlite

        e = create_engine("wrapperdialect://")

        eq_(e.dialect.name, "sqlite")
        assert isinstance(e.dialect, sqlite.dialect)

        eq_(
            WrapperFactory.mock_calls,
            [
                call.get_dialect_cls(url.make_url("sqlite://")),
                call.engine_created(e),
            ],
        ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:27,代码来源:test_parseconnect.py

示例5: test_prefix_with

# 需要导入模块: from sqlalchemy.dialects import sqlite [as 别名]
# 或者: from sqlalchemy.dialects.sqlite import dialect [as 别名]
def test_prefix_with(self):
        table1 = self.tables.mytable

        stmt = (
            table1.insert()
            .prefix_with("A", "B", dialect="mysql")
            .prefix_with("C", "D")
        )

        self.assert_compile(
            stmt,
            "INSERT C D INTO mytable (myid, name, description) "
            "VALUES (:myid, :name, :description)",
        )

        self.assert_compile(
            stmt,
            "INSERT A B C D INTO mytable (myid, name, description) "
            "VALUES (%s, %s, %s)",
            dialect=mysql.dialect(),
        ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:23,代码来源:test_insert.py

示例6: test_insert_from_select_seq

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

        t1 = Table(
            "t",
            m,
            Column("id", Integer, Sequence("id_seq"), primary_key=True),
            Column("data", String),
        )

        stmt = t1.insert().from_select(("data",), select([t1.c.data]))

        self.assert_compile(
            stmt,
            "INSERT INTO t (data, id) SELECT t.data, "
            "nextval('id_seq') AS next_value_1 FROM t",
            dialect=postgresql.dialect(),
        ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:20,代码来源:test_insert.py

示例7: test_insert_from_select_cte_follows_insert_two

# 需要导入模块: from sqlalchemy.dialects import sqlite [as 别名]
# 或者: from sqlalchemy.dialects.sqlite import dialect [as 别名]
def test_insert_from_select_cte_follows_insert_two(self):
        dialect = default.DefaultDialect()
        dialect.cte_follows_insert = True
        table1 = self.tables.mytable

        cte = table1.select().cte("c")
        stmt = cte.select()
        ins = table1.insert().from_select(table1.c, stmt)

        self.assert_compile(
            ins,
            "INSERT INTO mytable (myid, name, description) "
            "WITH c AS (SELECT mytable.myid AS myid, mytable.name AS name, "
            "mytable.description AS description FROM mytable) "
            "SELECT c.myid, c.name, c.description FROM c",
            dialect=dialect,
        ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:19,代码来源:test_insert.py

示例8: test_anticipate_no_pk_composite_pk_implicit_returning

# 需要导入模块: from sqlalchemy.dialects import sqlite [as 别名]
# 或者: from sqlalchemy.dialects.sqlite import dialect [as 别名]
def test_anticipate_no_pk_composite_pk_implicit_returning(self):
        t = Table(
            "t",
            MetaData(),
            Column("x", Integer, primary_key=True),
            Column("y", Integer, primary_key=True),
        )
        d = postgresql.dialect()
        d.implicit_returning = True

        with expect_warnings(
            "Column 't.y' is marked as a member.*"
            "Note that as of SQLAlchemy 1.1,"
        ):
            self.assert_compile(
                t.insert(),
                "INSERT INTO t (x) VALUES (%(x)s)",
                params={"x": 5},
                dialect=d,
            ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:22,代码来源:test_insert.py

示例9: test_anticipate_no_pk_composite_pk_prefetch

# 需要导入模块: from sqlalchemy.dialects import sqlite [as 别名]
# 或者: from sqlalchemy.dialects.sqlite import dialect [as 别名]
def test_anticipate_no_pk_composite_pk_prefetch(self):
        t = Table(
            "t",
            MetaData(),
            Column("x", Integer, primary_key=True),
            Column("y", Integer, primary_key=True),
        )
        d = postgresql.dialect()
        d.implicit_returning = False
        with expect_warnings(
            "Column 't.y' is marked as a member.*"
            "Note that as of SQLAlchemy 1.1,"
        ):
            self.assert_compile(
                t.insert(),
                "INSERT INTO t (x) VALUES (%(x)s)",
                params={"x": 5},
                dialect=d,
            ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:21,代码来源:test_insert.py

示例10: test_anticipate_no_pk_non_composite_pk_prefetch

# 需要导入模块: from sqlalchemy.dialects import sqlite [as 别名]
# 或者: from sqlalchemy.dialects.sqlite import dialect [as 别名]
def test_anticipate_no_pk_non_composite_pk_prefetch(self):
        t = Table(
            "t",
            MetaData(),
            Column("x", Integer, primary_key=True, autoincrement=False),
            Column("q", Integer),
        )
        d = postgresql.dialect()
        d.implicit_returning = False

        with expect_warnings(
            "Column 't.x' is marked as a member.*" "may not store NULL.$"
        ):
            self.assert_compile(
                t.insert(),
                "INSERT INTO t (q) VALUES (%(q)s)",
                params={"q": 5},
                dialect=d,
            ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:21,代码来源:test_insert.py

示例11: test_positional

# 需要导入模块: from sqlalchemy.dialects import sqlite [as 别名]
# 或者: from sqlalchemy.dialects.sqlite import dialect [as 别名]
def test_positional(self):
        table1 = self.tables.mytable

        values = [
            {"myid": 1, "name": "a", "description": "b"},
            {"myid": 2, "name": "c", "description": "d"},
            {"myid": 3, "name": "e", "description": "f"},
        ]

        checkpositional = (1, "a", "b", 2, "c", "d", 3, "e", "f")

        dialect = default.DefaultDialect()
        dialect.supports_multivalues_insert = True
        dialect.paramstyle = "format"
        dialect.positional = True

        self.assert_compile(
            table1.insert().values(values),
            "INSERT INTO mytable (myid, name, description) VALUES "
            "(%s, %s, %s), (%s, %s, %s), (%s, %s, %s)",
            checkpositional=checkpositional,
            dialect=dialect,
        ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:25,代码来源:test_insert.py

示例12: test_multi_multi

# 需要导入模块: from sqlalchemy.dialects import sqlite [as 别名]
# 或者: from sqlalchemy.dialects.sqlite import dialect [as 别名]
def test_multi_multi(self):
        table1 = self.tables.mytable

        stmt = table1.insert().values([{"myid": 1, "name": "d1"}])

        stmt = stmt.values(
            [{"myid": 2, "name": "d2"}, {"myid": 3, "name": "d3"}]
        )

        self.assert_compile(
            stmt,
            "INSERT INTO mytable (myid, name) VALUES (%(myid_m0)s, "
            "%(name_m0)s), (%(myid_m1)s, %(name_m1)s), (%(myid_m2)s, "
            "%(name_m2)s)",
            checkparams={
                "myid_m0": 1,
                "name_m0": "d1",
                "myid_m1": 2,
                "name_m1": "d2",
                "myid_m2": 3,
                "name_m2": "d3",
            },
            dialect=postgresql.dialect(),
        ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:26,代码来源:test_insert.py

示例13: test_sql_expression_pk_autoinc_lastinserted

# 需要导入模块: from sqlalchemy.dialects import sqlite [as 别名]
# 或者: from sqlalchemy.dialects.sqlite import dialect [as 别名]
def test_sql_expression_pk_autoinc_lastinserted(self):
        # test that postfetch isn't invoked for a SQL expression
        # in a primary key column.  the DB either needs to support a lastrowid
        # that can return it, or RETURNING.  [ticket:3133]
        metadata = MetaData()
        table = Table(
            "sometable",
            metadata,
            Column("id", Integer, primary_key=True),
            Column("data", String),
        )

        stmt = table.insert().return_defaults().values(id=func.foobar())
        compiled = stmt.compile(dialect=sqlite.dialect(), column_keys=["data"])
        eq_(compiled.postfetch, [])
        eq_(compiled.returning, [])

        self.assert_compile(
            stmt,
            "INSERT INTO sometable (id, data) VALUES " "(foobar(), ?)",
            checkparams={"data": "foo"},
            params={"data": "foo"},
            dialect=sqlite.dialect(),
        ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:26,代码来源:test_insert.py

示例14: setUp

# 需要导入模块: from sqlalchemy.dialects import sqlite [as 别名]
# 或者: from sqlalchemy.dialects.sqlite import dialect [as 别名]
def setUp(self):
        self.op = Operations(mock.Mock(opts={}))
        self.impl = sqlite.SQLiteImpl(
            sqlite_dialect.dialect(), None, False, False, None, {}
        ) 
开发者ID:sqlalchemy,项目名称:alembic,代码行数:7,代码来源:test_batch.py

示例15: test_add_table_opts

# 需要导入模块: from sqlalchemy.dialects import sqlite [as 别名]
# 或者: from sqlalchemy.dialects.sqlite import dialect [as 别名]
def test_add_table_opts(self):
        impl = self._simple_fixture(table_kwargs={"mysql_engine": "InnoDB"})
        self._assert_impl(impl, ddl_contains="ENGINE=InnoDB", dialect="mysql") 
开发者ID:sqlalchemy,项目名称:alembic,代码行数:5,代码来源:test_batch.py


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