ValueError:索引798处不支持的格式字符“P”(0x50)

问题描述 投票:0回答:1

我正在尝试执行查询以使用SQLQuery通过Python搜索数据库中的4个表。每次我尝试执行以下字符串作为查询时,它会给我上面的错误。

data2 = pd.read_sql("SELECT DateTime, vManagedEntity.DisplayName, vPerformanceRule.ObjectName, vPerformanceRule.CounterName, vPerformanceRuleInstance.InstanceName, SampleCount,AverageValue, MinValue, MaxValue FROM Perf.vPerfHourly INNER JOIN vPerformanceRuleInstance ON Perf.vPerfHourly.PerformanceRuleInstanceRowId =vPerformanceRuleInstance.PerformanceRuleInstanceRowId INNER JOIN vPerformanceRule ON vPerformanceRuleInstance.RuleRowId = vPerformanceRule.RuleRowId INNER JOIN vRelationship ON Perf.vPerfHourly.ManagedEntityRowId = vRelationship.TargetManagedEntityRowId INNER JOIN vManagedEntity ON vRelationship.SourceManagedEntityRowId =vManagedEntity.ManagedEntityRowId WHERE vPerformanceRule.ObjectName in ('Processor', 'Memory', 'Network Adapter', 'System', 'LogicalDisk') AND vPerformanceRule.CounterName in ('% Processor Time', 'Available Mbytes', 'Pages/sec', 'PercentBandwidthUsedTotal', 'Bytes Total/sec', 'Processor Queue Length', '% Free Space', 'Avg. Disk sec/Transfer', 'Current Disk Queue Length') AND LEFT(DisplayName,7) not in ('Active ', 'AD Doma', 'Windows ') AND (DateTime BETWEEN '%s' and '%s')" % (maxDate,currentTime),cnxn)

我验证了各种论坛但无法解决这个问题,如果删除maxDate和CurrentTime参数,则相同的查询有效。我在这里缺少什么

python mysql mysql-python
1个回答
1
投票

好像你错了一个%

 ....AND vPerformanceRule.CounterName in ('% Processor Time', 'Available Mbytes',.....

尝试删除

....AND vPerformanceRule.CounterName in ('Processor Time', 'Available Mbytes', ....

或逃避

© www.soinside.com 2019 - 2024. All rights reserved.