MySQL Forums
Forum List  »  General

Able to run statement in CLI and return a correct value but when run in a script it returns None
Posted by: Nick Davies
Date: November 01, 2021 05:34AM

Hello,

I'm still pretty new to MySQL so forgive me if this is a simple one. I set up a crypto database because it seemed like a good set of data to learn from.

I'm getting an error when running the below query in a python script but if I connect to the database via CLI it will run and return the correct value.

SELECT SUM(CASE type WHEN 'purchase' THEN TokenAmount WHEN 'sale' THEN -TokenAmount WHEN 'swap' THEN -TokenAmount WHEN 'gain' THEN TokenAmount END) FROM cryptotbl WHERE Token = 'ADA''

Running this in the script returns None. Running it in the CLI returns 20 (which is correct)

Thanks in advance for the help.

Nick

Options: ReplyQuote




Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.