I have a QODBC query for QuickBooks that generates Profit & Loss report with dynamic columns. The parameterized date value works to return the requested three daily values, AND 300+ more columns of None
!
sql1 = textwrap.dedent("""
sp_report
ProfitAndLossStandard
show
"AccountNumber",
"Text",
"Label",
"RowType",
"Amount" <-- dynamic
parameters
DateFrom=?,
DateTo=?,
ReportBasis='Accrual',
SummarizeColumnsBy='Day',
ReturnRows='All'
""")
cursor.execute(sql1, date(2022,11,1), date(2022,11,3))
for row in cursor.fetchall():
print(row)
The first row looks like this:
(None, 'Ordinary Income/Expense', None, 'TextRow', 366, None, None, None, None, None, None, None, None, ... (300+), None)
But if I declare the date parameter using the ODBC escape sequence:
parameters
DateFrom={d'2022-11-01'},
DateTo={d'2022-11-03'},
Then, I get the sensible results:
(None, 'Ordinary Income/Expense', None, 'TextRow', 4, None, None, None, None)
Why does my PyODBC parameterized date query return too much data?
Bonus: See the additional column (not named in the query) which shows 366
in the first query and 4
in the second--What is this?
Note: The None
values are not significant to the problem. It's the number of columns per row that's the issue.