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

Python converters.sqlrepr函数代码示例

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

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



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

示例1: test_datetime

def test_datetime():
    from datetime import datetime, date, time
    assert sqlrepr(datetime(2005, 7, 14, 13, 31, 2)) == "'2005-07-14 13:31:02.0'"
    assert sqlrepr(date(2005, 7, 14)) == "'2005-07-14'"
    assert sqlrepr(time(13, 31, 2)) == "'13:31:02.0'"
    # now dates before 1900
    assert sqlrepr(datetime(1428, 7, 14, 13, 31, 2)) == "'1428-07-14 13:31:02.0'"
    assert sqlrepr(date(1428, 7, 14)) == "'1428-07-14'"
开发者ID:sqlobject,项目名称:fullhistory,代码行数:8,代码来源:test_converters.py


示例2: test_insert

def test_insert():
    # Single column, no keyword arguments.
    instance = Insert('test', [('test',)])
    assert sqlrepr(instance, 'mysql') == "INSERT INTO test VALUES ('test')"

    # Multiple columns, no keyword arguments.
    instance2 = Insert('test', [('1st', '2nd', '3th', '4th')])
    assert sqlrepr(instance2, 'postgres') == "INSERT INTO test VALUES ('1st', '2nd', '3th', '4th')"

    # Multiple rows, multiple columns, "valueList" keyword argument.
    instance3 = Insert('test', valueList=[('a1', 'b1'), ('a2', 'b2'), ('a3', 'b3')])
    assert sqlrepr(instance3, 'sqlite') == "INSERT INTO test VALUES ('a1', 'b1'), ('a2', 'b2'), ('a3', 'b3')"

    # Multiple columns, "values" keyword argument.
    instance4 = Insert('test', values=('v1', 'v2', 'v3'))
    assert sqlrepr(instance4, 'mysql') == "INSERT INTO test VALUES ('v1', 'v2', 'v3')"

    # Single column, "valueList" keyword argument.
    instance5 = Insert('test', valueList=[('v1',)])
    assert sqlrepr(instance5, 'mysql') == "INSERT INTO test VALUES ('v1')"

    # Multiple rows, Multiple columns, template.
    instance6 = Insert('test', valueList=[('a1', 'b1'), ('a2', 'b2')], template=['col1', 'col2'])
    assert sqlrepr(instance6, 'mysql') == "INSERT INTO test (col1, col2) VALUES ('a1', 'b1'), ('a2', 'b2')"

    # Multiple columns, implicit template (dictionary value).
    instance7 = Insert('test', valueList=[{'col1': 'a1', 'col2': 'b1'}])
    assert sqlrepr(instance7, 'mysql') == "INSERT INTO test (col2, col1) VALUES ('b1', 'a1')"

    # Multiple rows, Multiple columns, implicit template.
    instance8 = Insert('test', valueList=[{'col1': 'a1', 'col2': 'b1'},
                                        {'col1': 'a2', 'col2': 'b2'}])
    assert sqlrepr(instance8, 'mysql') == "INSERT INTO test (col2, col1) VALUES ('b1', 'a1'), ('b2', 'a2')"
开发者ID:sqlobject,项目名称:fullhistory,代码行数:33,代码来源:test_converters.py


示例3: test_sets

def test_sets():
    try:
        set
    except NameError:
        pass
    else:
        assert sqlrepr(set([1])) == "(1)"
    if sys.version_info[:3] < (2, 6, 0): # Module sets was deprecated in Python 2.6
        try:
            from sets import Set
        except ImportError:
            pass
        else:
            assert sqlrepr(Set([1])) == "(1)"
开发者ID:Antexa,项目名称:htpc_ynh,代码行数:14,代码来源:test_converters.py


示例4: test_sets

def test_sets():
    try:
        set
    except NameError:
        pass
    else:
        assert sqlrepr(set([1])) == "(1)"
开发者ID:LutzSteinborn,项目名称:sqlobject,代码行数:7,代码来源:test_converters.py


示例5: test_datetime

def test_datetime():
    from datetime import datetime, date, time
    if SODateTimeCol.datetimeFormat.find('.%f') > 0:
        assert sqlrepr(datetime(2005, 7, 14, 13, 31, 2)) == \
            "'2005-07-14 13:31:02.000000'"
    else:
        assert sqlrepr(datetime(2005, 7, 14, 13, 31, 2)) == \
            "'2005-07-14 13:31:02'"
    assert sqlrepr(date(2005, 7, 14)) == "'2005-07-14'"
    if SOTimeCol.timeFormat.find('.%f') > 0:
        assert sqlrepr(time(13, 31, 2)) == "'13:31:02.000000'"
    else:
        assert sqlrepr(time(13, 31, 2)) == "'13:31:02'"
    # now dates before 1900
    if SODateTimeCol.datetimeFormat.find('.%f') > 0:
        assert sqlrepr(datetime(1428, 7, 14, 13, 31, 2)) == \
            "'1428-07-14 13:31:02.000000'"
    else:
        assert sqlrepr(datetime(1428, 7, 14, 13, 31, 2)) == \
            "'1428-07-14 13:31:02'"
    assert sqlrepr(date(1428, 7, 14)) == "'1428-07-14'"
开发者ID:sqlobject,项目名称:sqlobject,代码行数:21,代码来源:test_converters.py


示例6: test_string_newline

def test_string_newline():
    assert sqlrepr('A String\nAnother', 'postgres') == "E'A String\\nAnother'"
    assert sqlrepr('A String\nAnother', 'sqlite') == "'A String\nAnother'"
开发者ID:LutzSteinborn,项目名称:sqlobject,代码行数:3,代码来源:test_converters.py


示例7: test_simple_string

def test_simple_string():
    assert sqlrepr('A String', 'firebird') == "'A String'"
开发者ID:LutzSteinborn,项目名称:sqlobject,代码行数:2,代码来源:test_converters.py


示例8: test_select

def test_select():
    instance = Select('test')
    assert sqlrepr(instance, 'mysql') == "SELECT test"
开发者ID:LutzSteinborn,项目名称:sqlobject,代码行数:3,代码来源:test_converters.py


示例9: test_tuple

def test_tuple():
    assert sqlrepr(('one', 'two', 'three'), 'postgres') == \
        "('one', 'two', 'three')"
开发者ID:LutzSteinborn,项目名称:sqlobject,代码行数:3,代码来源:test_converters.py


示例10: test_none

def test_none():
    assert sqlrepr(None) == "NULL"
开发者ID:LutzSteinborn,项目名称:sqlobject,代码行数:2,代码来源:test_converters.py


示例11: test_integer

def test_integer():
    assert sqlrepr(10) == "10"
开发者ID:LutzSteinborn,项目名称:sqlobject,代码行数:2,代码来源:test_converters.py


示例12: test_string_

def test_string_():
    assert sqlrepr('A String\tAnother', 'postgres') == "E'A String\\tAnother'"
    assert sqlrepr('A String\'Another', 'firebird') == "'A String''Another'"
开发者ID:LutzSteinborn,项目名称:sqlobject,代码行数:3,代码来源:test_converters.py


示例13: test_constant

def test_constant():
    instance = SQLConstant('test')
    assert sqlrepr(instance) == repr(instance)
开发者ID:LutzSteinborn,项目名称:sqlobject,代码行数:3,代码来源:test_converters.py


示例14: test_call

def test_call():
    instance = SQLCall('test', ('test',))
    assert sqlrepr(instance, 'mysql') == "'test'('test')"
开发者ID:LutzSteinborn,项目名称:sqlobject,代码行数:3,代码来源:test_converters.py


示例15: test_op

def test_op():
    instance = SQLOp('and', 'this', 'that')
    assert sqlrepr(instance, 'mysql') == "(('this') AND ('that'))"
开发者ID:LutzSteinborn,项目名称:sqlobject,代码行数:3,代码来源:test_converters.py


示例16: test_trueclause

def test_trueclause():
    instance = SQLTrueClauseClass()
    assert sqlrepr(instance) == repr(instance)
开发者ID:LutzSteinborn,项目名称:sqlobject,代码行数:3,代码来源:test_converters.py


示例17: test_replace

def test_replace():
    instance = Replace('test', {'test': 'test'})
    assert sqlrepr(instance, 'mysql') == "REPLACE test SET test='test'"
开发者ID:LutzSteinborn,项目名称:sqlobject,代码行数:3,代码来源:test_converters.py


示例18: test_delete

def test_delete():
    instance = Delete('test', None)
    assert sqlrepr(instance, 'mysql') == "DELETE FROM test"
开发者ID:LutzSteinborn,项目名称:sqlobject,代码行数:3,代码来源:test_converters.py


示例19: test_update

def test_update():
    instance = Update('test', {'test': 'test'})
    assert sqlrepr(instance, 'mysql') == "UPDATE test SET test='test'"
开发者ID:LutzSteinborn,项目名称:sqlobject,代码行数:3,代码来源:test_converters.py


示例20: test_string_b

def test_string_b():
    assert sqlrepr('A String\bAnother', 'postgres') == "E'A String\\bAnother'"
开发者ID:LutzSteinborn,项目名称:sqlobject,代码行数:2,代码来源:test_converters.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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