當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。