• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python sqlite.dialect函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_load_dialect_impl_other

    def test_load_dialect_impl_other(self):
        """Assert with dialects other than PostgreSQL, a CHAR type is used."""
        guid = models.GUID()
        dialect = sqlite.dialect()

        result = guid.load_dialect_impl(dialect)

        self.assertTrue(isinstance(result, CHAR))
开发者ID:fedora-infra,项目名称:anitya,代码行数:8,代码来源:test_models.py


示例2: test_process_bind_param_none

    def test_process_bind_param_none(self):
        """Assert UUIDs with other dialects are hex-encoded strings of length 32."""
        guid = models.GUID()
        dialect = sqlite.dialect()

        result = guid.process_bind_param(None, dialect)

        self.assertTrue(result is None)
开发者ID:fedora-infra,项目名称:anitya,代码行数:8,代码来源:test_models.py


示例3: log_query

    def log_query(self, q):
        """
        Log Query
        :param q: Query
        """
        query_str =str(q.statement.compile(dialect=sqlite.dialect()))

        log.debug(query_str)
开发者ID:driver4567,项目名称:vote,代码行数:8,代码来源:demo_repository.py


示例4: pprint

def pprint(query_or_sql, engine):
    if isinstance(query_or_sql, Query):
        sql = query_or_sql.statement.compile(dialect=sqlite.dialect())
    else:
        sql = query_or_sql
    result_proxy = engine.execute(sql)
    p_table = from_db_cursor(result_proxy.cursor)
    print(p_table)
开发者ID:MacHu-GWU,项目名称:SQL-in-Python-for-DataScientist,代码行数:8,代码来源:util.py


示例5: test_process_result_short_string

    def test_process_result_short_string(self):
        """Assert when the result value is a short string, a native UUID is returned."""
        guid = models.GUID()
        uuid = uuid4()

        result = guid.process_result_value(str(uuid).replace("-", ""), sqlite.dialect())

        self.assertTrue(isinstance(result, UUID))
        self.assertEqual(uuid, result)
开发者ID:fedora-infra,项目名称:anitya,代码行数:9,代码来源:test_models.py


示例6: test_generic_now

    def test_generic_now(self):
        assert isinstance(func.now().type, sqltypes.DateTime)

        for ret, dialect in [
            ('CURRENT_TIMESTAMP', sqlite.dialect()),
            ('now()', postgresql.dialect()),
            ('now()', mysql.dialect()),
            ('CURRENT_TIMESTAMP', oracle.dialect())
        ]:
            self.assert_compile(func.now(), ret, dialect=dialect)
开发者ID:cpcloud,项目名称:sqlalchemy,代码行数:10,代码来源:test_functions.py


示例7: test_process_bind_param_str_other

    def test_process_bind_param_str_other(self):
        """Assert UUIDs with other dialects are hex-encoded strings of length 32."""
        guid = models.GUID()
        uuid = uuid4()
        dialect = sqlite.dialect()

        result = guid.process_bind_param(str(uuid), dialect)

        self.assertEqual(32, len(result))
        self.assertEqual(str(uuid).replace("-", ""), result)
开发者ID:fedora-infra,项目名称:anitya,代码行数:10,代码来源:test_models.py


示例8: log_query

    def log_query(q):
        """Log Query
        :param q: Query
        """
        statement = q.statement.compile(dialect=sqlite.dialect())
        if statement.params:
            query_str = '{0}\n{1}'.format(statement, statement.params)
        else:
            query_str = str(statement)

        log.debug(query_str)
开发者ID:driver4567,项目名称:vote,代码行数:11,代码来源:demo_repository.py


示例9: test_generic_random

    def test_generic_random(self):
        assert func.random().type == sqltypes.NULLTYPE
        assert isinstance(func.random(type_=Integer).type, Integer)

        for ret, dialect in [
            ('random()', sqlite.dialect()),
            ('random()', postgresql.dialect()),
            ('rand()', mysql.dialect()),
            ('random()', oracle.dialect())
        ]:
            self.assert_compile(func.random(), ret, dialect=dialect)
开发者ID:cpcloud,项目名称:sqlalchemy,代码行数:11,代码来源:test_functions.py


示例10: test_nextval_unsupported

    def test_nextval_unsupported(self):
        """test next_value() used on non-sequence platform
        raises NotImplementedError."""

        s = Sequence("my_seq")
        d = sqlite.dialect()
        assert_raises_message(
            NotImplementedError,
            "Dialect 'sqlite' does not support sequence increments.",
            s.next_value().compile,
            dialect=d
        )
开发者ID:Affirm,项目名称:sqlalchemy,代码行数:12,代码来源:test_defaults.py


示例11: test_sqlite_in_with_multiple_columns

def test_sqlite_in_with_multiple_columns():
    vals = (
        (1, '1'),
        (2, '2'),
    )
    cols = table.c.id, table.c.a
    select_in = sa.select(cols).where(sa.tuple_(*cols).in_(vals))
    select_and = sa.select(cols).where(sa.or_(
        sa.and_(col == value for col, value in zip(cols, vs))
        for vs in vals
    ))
    compiled_in = select_in.compile(dialect=sqlite.dialect())
    compiled_and = select_and.compile(dialect=sqlite.dialect())
    assert str(compiled_in) == str(compiled_and)
    update_in = table.update().where(sa.tuple_(*cols).in_(vals))
    update_and = table.update().where(sa.or_(
        sa.and_(col == value for col, value in zip(cols, vs))
        for vs in vals
    ))
    compiled_in = update_in.compile(dialect=sqlite.dialect())
    compiled_and = update_and.compile(dialect=sqlite.dialect())
    assert str(compiled_in) == str(compiled_and)
开发者ID:purpleP,项目名称:sqlalchemy-utils,代码行数:22,代码来源:test_compilers.py


示例12: test_sql_expression_pk_autoinc_lastinserted

    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:BY-jk,项目名称:sqlalchemy,代码行数:24,代码来源:test_insert.py


示例13: __init__

    def __init__(self, uri):
        parsed = urlparse.urlparse(uri)

        args = []
        if parsed.scheme in ("sqlite", "sqlite3"):
            args.append("sqlite3")
            if not parsed.path:
                args.append(":memory:")
            else:
                args.append(parsed.path)

            from sqlalchemy.dialects.sqlite import dialect
            self.dialect = dialect()

        self.pool = adbapi.ConnectionPool(*args, cp_min=1, cp_max=1)
开发者ID:Jc2k,项目名称:txsqlalchemy,代码行数:15,代码来源:connection.py


示例14: test_process_result_value_none

    def test_process_result_value_none(self):
        """Assert when the result value is None, None is returned."""
        guid = models.GUID()

        self.assertTrue(guid.process_result_value(None, sqlite.dialect()) is None)
开发者ID:fedora-infra,项目名称:anitya,代码行数:5,代码来源:test_models.py


示例15: test_mac_load_dialect_impl

 def test_mac_load_dialect_impl(self):
     dialect = self.mac.load_dialect_impl(sqlite.dialect())
     self.assertEqual(type(dialect), sqlite.CHAR)
开发者ID:blamarvt,项目名称:quark-1,代码行数:3,代码来源:test_db_custom_types.py


示例16: test_process_result_value_with_value

 def test_process_result_value_with_value(self):
     bind = self.inet.process_result_value(1.0, sqlite.dialect())
     self.assertEqual(bind, 1.0)
开发者ID:blamarvt,项目名称:quark-1,代码行数:3,代码来源:test_db_custom_types.py


示例17: test_process_bind_param_with_value

 def test_process_bind_param_with_value(self):
     bind = self.inet.process_bind_param("foo", sqlite.dialect())
     self.assertEqual(bind, "foo")
开发者ID:blamarvt,项目名称:quark-1,代码行数:3,代码来源:test_db_custom_types.py


示例18: test_inet_load_dialect_impl_sqlite

 def test_inet_load_dialect_impl_sqlite(self):
     dialect = self.inet.load_dialect_impl(sqlite.dialect())
     self.assertEqual(type(dialect), sqlite.CHAR)
开发者ID:blamarvt,项目名称:quark-1,代码行数:3,代码来源:test_db_custom_types.py


示例19: create_table_sql

from sqlalchemy.dialects import sqlite, mysql

__all__ = ['sqlite_dialect', 'mysql_dialect', 'create_table_sql', 'sqlite3']

sqlite_dialect = sqlite.dialect()
mysql_dialect = mysql.dialect()

def create_table_sql(table, dialect):
    from sqlalchemy.schema import CreateTable
    return str(CreateTable(table).compile(dialect=dialect)).strip()

def sqlite3(db_file, command):
    import subprocess
    return subprocess.check_output(['sqlite3', db_file, command])

开发者ID:imsardine,项目名称:learning,代码行数:14,代码来源:__init__.py


示例20: test_match_1

 def test_match_1(self):
     self.assert_compile(self.table1.c.myid.match('somstr'),
                     "mytable.myid MATCH ?",
                     dialect=sqlite.dialect())
开发者ID:e0ne,项目名称:sqlalchemy,代码行数:4,代码来源:test_operators.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python base.dialect函数代码示例发布时间:2022-05-27
下一篇:
Python registry.register函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap