Re: Handling (None,) Query Results
От
Christophe Pettus
Тема
Re: Handling (None,) Query Results
Дата
Msg-id
0609481B-8907-402E-B995-9C0DEC590B41@thebuild.com
Ответ на
Handling (None,) Query Results (Hagen Finley)
Список
Дерево обсуждения
Handling (None,) Query Results Hagen Finley <hagen@datasundae.com>
Re: Handling (None,) Query Results Christophe Pettus <xof@thebuild.com>
Re: Handling (None,) Query Results Adrian Klaver <adrian.klaver@aklaver.com>
RE: Handling (None,) Query Results <hagen@datasundae.com>
Re: Handling (None,) Query Results Adrian Klaver <adrian.klaver@aklaver.com>
> On Dec 5, 2020, at 07:57, Hagen Finley wrote:
> 1. (Decimal('450992.10'),) to a 450992.10?
>
> 2. (None,) to 0.00?
> Thanks for your thoughts on this question.
For #2, you can do that directly in the query:
SELECT COALESCE(SUM(revusd), 0) FROM sfdc where saccount = 'Big Company' AND stage LIKE 'Win%';
For #1, you can write it more compactly, of course:
commitd1 = int(cur.fetchone()[0])
Note that there's no such thing as an int with value 450992.10, because that's not an integer. It will truncate it if you cast it to int, or you can use other operations to round it the way you'd like do.
As you probably know, it's returning a tuple because you are getting back a row of one column, and a Decimal because (presumably) that's what type revusd is in the database.
--
-- Christophe Pettus
xof@thebuild.com
В списке psycopg по дате отправления