public inbox for [email protected]  
help / color / mirror / Atom feed
From: Daniel Johnson <[email protected]>
To: [email protected]
Subject: Re: Parameter in SQL query being misinterpreted
Date: Fri, 6 Dec 2024 17:21:10 -0600
Message-ID: <[email protected]> (raw)
In-Reply-To: <CA+mi_8YTTz0CXGRgrp9+DF-gNJZ5+Wv2uiMYYLO5UbTtZUi2Sw@mail.gmail.com>
References: <[email protected]>
	<CA+mi_8YTTz0CXGRgrp9+DF-gNJZ5+Wv2uiMYYLO5UbTtZUi2Sw@mail.gmail.com>

On 12/5/24 20:39, Daniele Varrazzo wrote:
<snip>
> Adrian has already provided a few workarounds for the problem you
> report - thank you very much!. The one I prefer is however the
> following, because it does without string operations: it makes use of
> the possibility to multiply an interval by a scalar:
> 
>      >>> cur.execute("select now(), now() + %s * '1 second'::interval",
> (10,)).fetchone()
>      (datetime.datetime(2024, 12, 6, 2, 33, 32, 117134,
> tzinfo=zoneinfo.ZoneInfo(key='Europe/London')),
>       datetime.datetime(2024, 12, 6, 2, 33, 42, 117134,
> tzinfo=zoneinfo.ZoneInfo(key='Europe/London')))

Oh I hadn't even thought about multiplying an interval, that's a very 
clean approach.  Prior to e-mailing the list I'd tried something similar 
to (but not as thorough as) Adrian's suggestion and it had failed, but 
if it works I like the look of this.

I vaguely recall having a similar interval manipulation headache in a 
PHP portion of this project, I shall try the same thing there.

Thank you so much!

Daniel Johnson
[email protected]







view thread (6+ messages)

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]
  Subject: Re: Parameter in SQL query being misinterpreted
  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