本文整理汇总了Python中sqlalchemy.sql.util._repr_params方法的典型用法代码示例。如果您正苦于以下问题:Python util._repr_params方法的具体用法?Python util._repr_params怎么用?Python util._repr_params使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sqlalchemy.sql.util
的用法示例。
在下文中一共展示了util._repr_params方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_repr_params_positional_list
# 需要导入模块: from sqlalchemy.sql import util [as 别名]
# 或者: from sqlalchemy.sql.util import _repr_params [as 别名]
def test_repr_params_positional_list(self):
# given non-multi-params in a list. repr params with
# per-element truncation, mostly does the exact same thing
eq_(
repr(
sql_util._repr_params(
[[i for i in range(300)], 5],
batches=10,
max_chars=80,
ismulti=False,
)
),
"[[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 1 ... "
"(1310 characters truncated) ... "
"292, 293, 294, 295, 296, 297, 298, 299], 5]",
)
示例2: test_repr_params_ismulti_named_dict
# 需要导入模块: from sqlalchemy.sql import util [as 别名]
# 或者: from sqlalchemy.sql.util import _repr_params [as 别名]
def test_repr_params_ismulti_named_dict(self):
# given non-multi-params in a list. repr params with
# per-element truncation, mostly does the exact same thing
param = {"key_%s" % i: i for i in range(10)}
eq_(
repr(
sql_util._repr_params(
[param for j in range(50)],
batches=5,
max_chars=80,
ismulti=True,
)
),
"[%(param)r, %(param)r, %(param)r ... "
"displaying 5 of 50 total bound parameter sets ... "
"%(param)r, %(param)r]" % {"param": param},
)
示例3: test_repr_params_ismulti_list
# 需要导入模块: from sqlalchemy.sql import util [as 别名]
# 或者: from sqlalchemy.sql.util import _repr_params [as 别名]
def test_repr_params_ismulti_list(self):
# given multi-params in a list. repr params with
# per-element truncation, mostly does the exact same thing
eq_(
repr(
sql_util._repr_params(
[
[[i for i in range(300)], 5],
[[i for i in range(300)], 5],
[[i for i in range(300)], 5],
],
batches=10,
max_chars=80,
ismulti=True,
)
),
"[[[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 1 ... "
"(1310 characters truncated) ... 292, 293, 294, 295, 296, 297, "
"298, 299], 5], [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 1 ... "
"(1310 characters truncated) ... 292, 293, 294, 295, 296, 297, "
"298, 299], 5], [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 1 ... "
"(1310 characters truncated) ... 292, 293, 294, 295, 296, 297, "
"298, 299], 5]]",
)
示例4: __str__
# 需要导入模块: from sqlalchemy.sql import util [as 别名]
# 或者: from sqlalchemy.sql.util import _repr_params [as 别名]
def __str__(self):
from sqlalchemy.sql import util
details = [SQLAlchemyError.__str__(self)]
if self.statement:
details.append("[SQL: %r]" % self.statement)
if self.params:
params_repr = util._repr_params(self.params, 10)
details.append("[parameters: %r]" % params_repr)
return ' '.join([
"(%s)" % det for det in self.detail
] + details)
示例5: __str__
# 需要导入模块: from sqlalchemy.sql import util [as 别名]
# 或者: from sqlalchemy.sql.util import _repr_params [as 别名]
def __str__(self):
from sqlalchemy.sql import util
details = [self._message()]
if self.statement:
details.append("[SQL: %r]" % self.statement)
if self.params:
params_repr = util._repr_params(self.params, 10)
details.append("[parameters: %r]" % params_repr)
code_str = self._code_str()
if code_str:
details.append(code_str)
return ' '.join([
"(%s)" % det for det in self.detail
] + details)
示例6: __str__
# 需要导入模块: from sqlalchemy.sql import util [as 别名]
# 或者: from sqlalchemy.sql.util import _repr_params [as 别名]
def __str__(self):
from sqlalchemy.sql import util
params_repr = util._repr_params(self.params, 10)
return ' '.join([
"(%s)" % det for det in self.detail
] + [
SQLAlchemyError.__str__(self),
repr(self.statement), repr(params_repr)
])
示例7: _sql_message
# 需要导入模块: from sqlalchemy.sql import util [as 别名]
# 或者: from sqlalchemy.sql.util import _repr_params [as 别名]
def _sql_message(self, as_unicode):
from sqlalchemy.sql import util
details = [self._message(as_unicode=as_unicode)]
if self.statement:
if not as_unicode and not compat.py3k:
stmt_detail = "[SQL: %s]" % compat.safe_bytestring(
self.statement
)
else:
stmt_detail = "[SQL: %s]" % self.statement
details.append(stmt_detail)
if self.params:
if self.hide_parameters:
details.append(
"[SQL parameters hidden due to hide_parameters=True]"
)
else:
params_repr = util._repr_params(
self.params, 10, ismulti=self.ismulti
)
details.append("[parameters: %r]" % params_repr)
code_str = self._code_str()
if code_str:
details.append(code_str)
return "\n".join(["(%s)" % det for det in self.detail] + details)
示例8: test_repr_params_large_list_of_dict
# 需要导入模块: from sqlalchemy.sql import util [as 别名]
# 或者: from sqlalchemy.sql.util import _repr_params [as 别名]
def test_repr_params_large_list_of_dict(self):
eq_(
repr(
sql_util._repr_params(
[{"data": str(i)} for i in range(100)],
batches=10,
ismulti=True,
)
),
"[{'data': '0'}, {'data': '1'}, {'data': '2'}, {'data': '3'}, "
"{'data': '4'}, {'data': '5'}, {'data': '6'}, {'data': '7'}"
" ... displaying 10 of 100 total bound "
"parameter sets ... {'data': '98'}, {'data': '99'}]",
)
示例9: test_repr_params_positional_array
# 需要导入模块: from sqlalchemy.sql import util [as 别名]
# 或者: from sqlalchemy.sql.util import _repr_params [as 别名]
def test_repr_params_positional_array(self):
eq_(
repr(
sql_util._repr_params(
[[1, 2, 3], 5], batches=10, ismulti=False
)
),
"[[1, 2, 3], 5]",
)
示例10: test_repr_params_unknown_list
# 需要导入模块: from sqlalchemy.sql import util [as 别名]
# 或者: from sqlalchemy.sql.util import _repr_params [as 别名]
def test_repr_params_unknown_list(self):
# not known if given multiparams or not. repr params with
# straight truncation
eq_(
repr(
sql_util._repr_params(
[[i for i in range(300)], 5], batches=10, max_chars=80
)
),
"[[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ... "
"(1315 characters truncated) ... , 293, 294, 295, 296, "
"297, 298, 299], 5]",
)
示例11: __str__
# 需要导入模块: from sqlalchemy.sql import util [as 别名]
# 或者: from sqlalchemy.sql.util import _repr_params [as 别名]
def __str__(self):
from sqlalchemy.sql import util
params_repr = util._repr_params(self.params, 10)
return ' '.join([
"(%s)" % det for det in self.detail
] + [
SQLAlchemyError.__str__(self),
repr(self.statement), repr(params_repr)
])