public inbox for [email protected]  
help / color / mirror / Atom feed
From: Christophe Pettus <[email protected]>
To: Hagen Finley <[email protected]>
Cc: [email protected]
Subject: Re: Handling (None,) Query Results
Date: Sat, 5 Dec 2020 08:02:25 -0800
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>



> On Dec 5, 2020, at 07:57, Hagen Finley <[email protected]> wrote:
> 1. (Decimal('450992.10'),) to a <class 'int'> 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
   [email protected]






view thread (5+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: Handling (None,) Query Results
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox