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

Python pyodbc.dialect函数代码示例

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

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



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

示例1: test_pyodbc_disconnect

    def test_pyodbc_disconnect(self):
        dialect = pyodbc.dialect()

        class MockDBAPIError(Exception):
            pass

        class MockProgrammingError(MockDBAPIError):
            pass

        dialect.dbapi = Mock(
            Error=MockDBAPIError, ProgrammingError=MockProgrammingError)

        for error in [
            MockDBAPIError("[%s] some pyodbc message" % code)
            for code in [
                '08S01', '01002', '08003', '08007',
                '08S02', '08001', 'HYT00', 'HY010']
        ] + [
            MockProgrammingError(message)
            for message in [
                "(some pyodbc stuff) The cursor's connection has been closed.",
                "(some pyodbc stuff) Attempt to use a closed connection."
            ]
        ]:
            eq_(dialect.is_disconnect(error, None, None), True)

        eq_(dialect.is_disconnect(
            MockProgrammingError("not an error"), None, None), False)
开发者ID:nakagami,项目名称:sqlalchemy,代码行数:28,代码来源:test_engine.py


示例2: test_pyodbc_host_no_driver

    def test_pyodbc_host_no_driver(self):
        dialect = pyodbc.dialect()
        u = url.make_url("mssql://username:[email protected]/database")

        def go():
            return dialect.create_connect_args(u)

        connection = assert_warnings(
            go,
            [
                "No driver name specified; this is expected by "
                "PyODBC when using DSN-less connections"
            ],
        )

        eq_(
            [
                [
                    "Server=hostspec;Database=database;UI"
                    "D=username;PWD=password"
                ],
                {},
            ],
            connection,
        )
开发者ID:monetate,项目名称:sqlalchemy,代码行数:25,代码来源:test_engine.py


示例3: test_pyodbc_odbc_connect_with_dsn

 def test_pyodbc_odbc_connect_with_dsn(self):
     dialect = pyodbc.dialect()
     u = url.make_url(
         "mssql:///?odbc_connect=dsn%3Dmydsn%3BDatabase" "%3Ddatabase%3BUID%3Dusername%3BPWD%3Dpassword"
     )
     connection = dialect.create_connect_args(u)
     eq_([["dsn=mydsn;Database=database;UID=username;PWD=password"], {}], connection)
开发者ID:balagopalraj,项目名称:clearlinux,代码行数:7,代码来源:test_engine.py


示例4: test_pyodbc_connect_dsn_extra

 def test_pyodbc_connect_dsn_extra(self):
     dialect = pyodbc.dialect()
     u = url.make_url("mssql://username:[email protected]/?LANGUAGE=us_" "english&foo=bar")
     connection = dialect.create_connect_args(u)
     dsn_string = connection[0][0]
     assert ";LANGUAGE=us_english" in dsn_string
     assert ";foo=bar" in dsn_string
开发者ID:balagopalraj,项目名称:clearlinux,代码行数:7,代码来源:test_engine.py


示例5: test_pyodbc_connect_comma_port

 def test_pyodbc_connect_comma_port(self):
     dialect = pyodbc.dialect()
     u = \
         url.make_url('mssql://username:[email protected]:12345/data'
                      'base')
     connection = dialect.create_connect_args(u)
     eq_([['DRIVER={SQL Server};Server=hostspec,12345;Database=datab'
         'ase;UID=username;PWD=password'], {}], connection)
开发者ID:23andMe,项目名称:sqlalchemy,代码行数:8,代码来源:test_engine.py


示例6: test_pyodbc_hostname

 def test_pyodbc_hostname(self):
     dialect = pyodbc.dialect()
     u = url.make_url(
         'mssql://username:[email protected]/database?driver=SQL+Server'
     )
     connection = dialect.create_connect_args(u)
     eq_([['DRIVER={SQL Server};Server=hostspec;Database=database;UI'
         'D=username;PWD=password'], {}], connection)
开发者ID:anti-social,项目名称:sqlalchemy,代码行数:8,代码来源:test_engine.py


示例7: test_pyodbc_connect_config_port

 def test_pyodbc_connect_config_port(self):
     dialect = pyodbc.dialect()
     u = \
         url.make_url('mssql://username:[email protected]/database?p'
                      'ort=12345')
     connection = dialect.create_connect_args(u)
     eq_([['DRIVER={SQL Server};Server=hostspec;Database=database;UI'
         'D=username;PWD=password;port=12345'], {}], connection)
开发者ID:23andMe,项目名称:sqlalchemy,代码行数:8,代码来源:test_engine.py


示例8: test_pyodbc_connect_comma_port

 def test_pyodbc_connect_comma_port(self):
     dialect = pyodbc.dialect()
     u = url.make_url("mssql://username:[email protected]:12345/data" "base")
     connection = dialect.create_connect_args(u)
     eq_(
         [["DRIVER={SQL Server};Server=hostspec,12345;Database=datab" "ase;UID=username;PWD=password"], {}],
         connection,
     )
开发者ID:balagopalraj,项目名称:clearlinux,代码行数:8,代码来源:test_engine.py


示例9: test_pyodbc_odbc_connect

 def test_pyodbc_odbc_connect(self):
     dialect = pyodbc.dialect()
     u = \
         url.make_url('mssql:///?odbc_connect=DRIVER%3D%7BSQL+Server'
                      '%7D%3BServer%3Dhostspec%3BDatabase%3Ddatabase'
                      '%3BUID%3Dusername%3BPWD%3Dpassword')
     connection = dialect.create_connect_args(u)
     eq_([['DRIVER={SQL Server};Server=hostspec;Database=database;UI'
         'D=username;PWD=password'], {}], connection)
开发者ID:23andMe,项目名称:sqlalchemy,代码行数:9,代码来源:test_engine.py


示例10: test_pyodbc_odbc_connect_ignores_other_values

 def test_pyodbc_odbc_connect_ignores_other_values(self):
     dialect = pyodbc.dialect()
     u = \
         url.make_url('mssql://userdiff:[email protected]/dbdiff?od'
                      'bc_connect=DRIVER%3D%7BSQL+Server%7D%3BServer'
                      '%3Dhostspec%3BDatabase%3Ddatabase%3BUID%3Duse'
                      'rname%3BPWD%3Dpassword')
     connection = dialect.create_connect_args(u)
     eq_([['DRIVER={SQL Server};Server=hostspec;Database=database;UI'
         'D=username;PWD=password'], {}], connection)
开发者ID:23andMe,项目名称:sqlalchemy,代码行数:10,代码来源:test_engine.py


示例11: test_pyodbc_extra_connect

 def test_pyodbc_extra_connect(self):
     dialect = pyodbc.dialect()
     u = \
         url.make_url('mssql://username:[email protected]/database?L'
                      'ANGUAGE=us_english&foo=bar')
     connection = dialect.create_connect_args(u)
     eq_(connection[1], {})
     eq_(connection[0][0]
         in ('DRIVER={SQL Server};Server=hostspec;Database=database;'
         'UID=username;PWD=password;foo=bar;LANGUAGE=us_english',
         'DRIVER={SQL Server};Server=hostspec;Database=database;UID='
         'username;PWD=password;LANGUAGE=us_english;foo=bar'), True)
开发者ID:23andMe,项目名称:sqlalchemy,代码行数:12,代码来源:test_engine.py


示例12: test_pyodbc_extra_connect

 def test_pyodbc_extra_connect(self):
     dialect = pyodbc.dialect()
     u = url.make_url("mssql://username:[email protected]/database?L" "ANGUAGE=us_english&foo=bar")
     connection = dialect.create_connect_args(u)
     eq_(connection[1], {})
     eq_(
         connection[0][0]
         in (
             "DRIVER={SQL Server};Server=hostspec;Database=database;"
             "UID=username;PWD=password;foo=bar;LANGUAGE=us_english",
             "DRIVER={SQL Server};Server=hostspec;Database=database;UID="
             "username;PWD=password;LANGUAGE=us_english;foo=bar",
         ),
         True,
     )
开发者ID:balagopalraj,项目名称:clearlinux,代码行数:15,代码来源:test_engine.py


示例13: test_pyodbc_connect_config_port

 def test_pyodbc_connect_config_port(self):
     dialect = pyodbc.dialect()
     u = url.make_url(
         "mssql://username:[email protected]/database?p"
         "ort=12345&driver=SQL+Server"
     )
     connection = dialect.create_connect_args(u)
     eq_(
         [
             [
                 "DRIVER={SQL Server};Server=hostspec;Database=database;UI"
                 "D=username;PWD=password;port=12345"
             ],
             {},
         ],
         connection,
     )
开发者ID:monetate,项目名称:sqlalchemy,代码行数:17,代码来源:test_engine.py


示例14: test_pyodbc_odbc_connect

 def test_pyodbc_odbc_connect(self):
     dialect = pyodbc.dialect()
     u = url.make_url(
         "mssql:///?odbc_connect=DRIVER%3D%7BSQL+Server"
         "%7D%3BServer%3Dhostspec%3BDatabase%3Ddatabase"
         "%3BUID%3Dusername%3BPWD%3Dpassword"
     )
     connection = dialect.create_connect_args(u)
     eq_(
         [
             [
                 "DRIVER={SQL Server};Server=hostspec;Database=database;UI"
                 "D=username;PWD=password"
             ],
             {},
         ],
         connection,
     )
开发者ID:monetate,项目名称:sqlalchemy,代码行数:18,代码来源:test_engine.py


示例15: test_pyodbc_odbc_connect_ignores_other_values

 def test_pyodbc_odbc_connect_ignores_other_values(self):
     dialect = pyodbc.dialect()
     u = url.make_url(
         "mssql://userdiff:[email protected]/dbdiff?od"
         "bc_connect=DRIVER%3D%7BSQL+Server%7D%3BServer"
         "%3Dhostspec%3BDatabase%3Ddatabase%3BUID%3Duse"
         "rname%3BPWD%3Dpassword"
     )
     connection = dialect.create_connect_args(u)
     eq_(
         [
             [
                 "DRIVER={SQL Server};Server=hostspec;Database=database;UI"
                 "D=username;PWD=password"
             ],
             {},
         ],
         connection,
     )
开发者ID:monetate,项目名称:sqlalchemy,代码行数:19,代码来源:test_engine.py


示例16: test_pyodbc_token_injection

    def test_pyodbc_token_injection(self):
        token1 = "someuser%3BPORT%3D50001"
        token2 = "somepw%3BPORT%3D50001"
        token3 = "somehost%3BPORT%3D50001"
        token4 = "somedb%3BPORT%3D50001"

        u = url.make_url(
            'mssql+pyodbc://%s:%[email protected]%s/%s?driver=foob' % (
                token1, token2, token3, token4
            )
        )
        dialect = pyodbc.dialect()
        connection = dialect.create_connect_args(u)
        eq_(
            [[
                "DRIVER={foob};Server=somehost%3BPORT%3D50001;"
                "Database=somedb%3BPORT%3D50001;UID='someuser;PORT=50001';"
                "PWD='somepw;PORT=50001'"], {}],
            connection
        )
开发者ID:anti-social,项目名称:sqlalchemy,代码行数:20,代码来源:test_engine.py


示例17: test_pyodbc_connect_dsn_non_trusted

 def test_pyodbc_connect_dsn_non_trusted(self):
     dialect = pyodbc.dialect()
     u = url.make_url('mssql://username:[email protected]')
     connection = dialect.create_connect_args(u)
     eq_([['dsn=mydsn;UID=username;PWD=password'], {}], connection)
开发者ID:23andMe,项目名称:sqlalchemy,代码行数:5,代码来源:test_engine.py


示例18: test_pyodbc_connect_old_style_dsn_trusted

 def test_pyodbc_connect_old_style_dsn_trusted(self):
     dialect = pyodbc.dialect()
     u = url.make_url('mssql:///?dsn=mydsn')
     connection = dialect.create_connect_args(u)
     eq_([['dsn=mydsn;Trusted_Connection=Yes'], {}], connection)
开发者ID:23andMe,项目名称:sqlalchemy,代码行数:5,代码来源:test_engine.py


示例19: test_pyodbc_connect_dsn_trusted

 def test_pyodbc_connect_dsn_trusted(self):
     dialect = pyodbc.dialect()
     u = url.make_url("mssql://mydsn")
     connection = dialect.create_connect_args(u)
     eq_([["dsn=mydsn;Trusted_Connection=Yes"], {}], connection)
开发者ID:monetate,项目名称:sqlalchemy,代码行数:5,代码来源:test_engine.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python mysql.dialect函数代码示例发布时间:2022-05-27
下一篇:
Python mssql.dialect函数代码示例发布时间: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