changeset 25fa27914f88 in modules/account:default
details: https://hg.tryton.org/modules/account?cmd=changeset&node=25fa27914f88
description:
Replace cursor fetchall by iteration over cursor
issue5817
review335831003
diffstat:
account.py | 5 ++---
journal.py | 2 +-
move.py | 8 ++++----
party.py | 2 +-
4 files changed, 8 insertions(+), 9 deletions(-)
diffs (83 lines):
diff -r cc5eb717c875 -r 25fa27914f88 account.py
--- a/account.py Sat Mar 20 12:50:45 2021 +0100
+++ b/account.py Sun Mar 21 16:09:12 2021 +0100
@@ -932,8 +932,7 @@
Sum(Coalesce(line.debit, 0) - Coalesce(line.credit, 0)),
where=red_sql & line_query,
group_by=table_a.id))
- result = cursor.fetchall()
- balances.update(dict(result))
+ balances.update(dict(cursor))
for account in accounts:
# SQLite uses float for SUM
@@ -981,7 +980,7 @@
).select(*columns,
where=red_sql & line_query,
group_by=table.id))
- for row in cursor.fetchall():
+ for row in cursor:
account_id = row[0]
for i, name in enumerate(names, 1):
# SQLite uses float for SUM
diff -r cc5eb717c875 -r 25fa27914f88 journal.py
--- a/journal.py Sat Mar 20 12:50:45 2021 +0100
+++ b/journal.py Sun Mar 21 16:09:12 2021 +0100
@@ -138,7 +138,7 @@
where=where & red_sql,
group_by=move.journal)
cursor.execute(*query)
- for journal_id, debit, credit in cursor.fetchall():
+ for journal_id, debit, credit in cursor:
# SQLite uses float for SUM
if not isinstance(debit, Decimal):
debit = Decimal(str(debit))
diff -r cc5eb717c875 -r 25fa27914f88 move.py
--- a/move.py Sat Mar 20 12:50:45 2021 +0100
+++ b/move.py Sun Mar 21 16:09:12 2021 +0100
@@ -327,13 +327,13 @@
Sum(line.debit - line.credit),
where=red_sql,
group_by=line.move))
- amounts.update(dict(cursor.fetchall()))
+ amounts.update(dict(cursor))
cursor.execute(*line.select(line.move, line.id,
where=red_sql & (line.state == 'draft'),
order_by=line.move))
move2draft_lines.update(dict((k, [j[1] for j in g])
- for k, g in groupby(cursor.fetchall(), itemgetter(0))))
+ for k, g in groupby(cursor, itemgetter(0))))
valid_moves = []
draft_moves = []
@@ -1615,7 +1615,7 @@
Sum(balance) > 0),
else_=False)
)))
- return [a for a, in cursor.fetchall()]
+ return [a for a, in cursor]
def get_parties(self, account, _balanced=False, party=None):
'Return a list party to reconcile for the account'
@@ -1648,7 +1648,7 @@
where=where,
group_by=line.party,
having=having))
- return [p for p, in cursor.fetchall()]
+ return [p for p, in cursor]
def transition_next_(self):
diff -r cc5eb717c875 -r 25fa27914f88 party.py
--- a/party.py Sat Mar 20 12:50:45 2021 +0100
+++ b/party.py Sun Mar 21 16:09:12 2021 +0100
@@ -176,7 +176,7 @@
& party_where
& today_where),
group_by=line.party))
- for party, value in cursor.fetchall():
+ for party, value in cursor:
# SQLite uses float for SUM
if not isinstance(value, Decimal):
value = Decimal(str(value))