我有一个表格,需要更新文本列。 report_2_comments列是文本列。当我用一个小字符串更新列 - “这是测试消息”时,我没有任何问题但是当我使用下面给出的消息更新时,我收到此错误。
e == not enough arguments for format string
context = DbContext()
try:
qry = """Update Report_Table
set {2} = '{3}'
where valid_flag = 'Y' and report_status = 'C'
and report_name = '{0}'
and date(report_run_date) = '{1}';
""".format('Daily Errors Report'
, '2016-07-09', 'report_2_comments',
'8-3-2016 01:00 EST Affected DC region 1,000 errors over 2.5 hours (2%) 8-3-2016 13:00 EST Affected Virginia 500 errors over 11 hours (2%) 1233 8-3-2016 13:00 EST Affected 212/1412121001 - Date/skljld (sdlkjd)NOT_FOUND) 90,800 errors over 11 hours (2%) sldkdsdsd Fiber cut 8-3-2016 17:00 EST Affected 16703 - sdsdsd, WV (Tune Error) 15,400 errors over 7.5 hours (0.6%) sdkjd dskdjhsd sdkjhd')
print 'update qry == ', qry
output = context.execute(qry,())
except Exception as e:
print 'e == ', e
QRY
Update vbo.Report_Table
set report_2_comments = '8-3-2016 01:00 EST Affected DC region 1,000 errors over 2.5 hours (2%) 8-3-2016 13:00 EST Affected Virginia 500 errors over 11 hours (2%) 1233 8-3-2016 13:00 EST Affected 212/1412121001 - Date/skljld (sdlkjd)NOT_FOUND) 90,800 errors over 11 hours (2%) sldkdsdsd Fiber cut 8-3-2016 17:00 EST Affected 16703 - sdsdsd, WV (Tune Error) 15,400 errors over 7.5 hours (0.6%) sdkjd dskdjhsd sdkjhd'
where valid_flag = 'Y' and report_status = 'C'
and report_name = 'Daily Errors Report'
and date(report_run_date) = '2016-07-09';
表格定义。
CREATE TABLE Report_Table (
id bigint(19) NOT NULL auto_increment,
report_name varchar(200),
report_run_date datetime,
report_status char(25),
valid_flag char(1),
report_1_comments text(65535),
report_2_comments text(65535),
report_3_comments text(65535),
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;