Re: [sqlalchemy] Common datetime call

2021-06-18 Thread Joseph L. Casale
On Fri, Jun 18, 2021 at 3:45 AM Simon King  wrote:

> On Fri, Jun 18, 2021 at 12:21 AM jca...@gmail.com 
> wrote:
> >
> > Hi,
> > Does a means exist to generically call a local datetime func such that
> it renders as SYSDATE in Oracle and GETDATE() in SQL Server?
> >
> > Thanks,
> > jlc
> >
>
> Do you need those functions explicitly? I think both databases support
> the CURRENT_TIMESTAMP function (which you'd access as
> sqlalchemy.func.current_timestamp()).
>
> If you really do want to use different functions based on the
> database, the compiler extension is what you want:
>
> https://docs.sqlalchemy.org/en/14/core/compiler.html#utc-timestamp-function
>
> Hope that helps,
>
> Simon
>

Hi Simon,
I originally was relying on a utc datetime and was surprised to see that was
inconsistent with the rest of the application. As surprising as it, I do
need a
local time and your example is perfect.

Thank you very much!
jlc

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/CAMogvAeTJ_T6YyFcj2V01wuEC4CXhsHnPN_rgSVsvq%2B80YHadQ%40mail.gmail.com.


Re: [sqlalchemy] Common datetime call

2021-06-18 Thread Simon King
On Fri, Jun 18, 2021 at 12:21 AM jca...@gmail.com  wrote:
>
> Hi,
> Does a means exist to generically call a local datetime func such that it 
> renders as SYSDATE in Oracle and GETDATE() in SQL Server?
>
> Thanks,
> jlc
>

Do you need those functions explicitly? I think both databases support
the CURRENT_TIMESTAMP function (which you'd access as
sqlalchemy.func.current_timestamp()).

If you really do want to use different functions based on the
database, the compiler extension is what you want:

https://docs.sqlalchemy.org/en/14/core/compiler.html#utc-timestamp-function

Hope that helps,

Simon

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/CAFHwexduw0SbGTZw09sMH457Eqf1zWQ8hs967HoBrTV_0R6g0Q%40mail.gmail.com.


[sqlalchemy] Common datetime call

2021-06-17 Thread jca...@gmail.com
Hi,
Does a means exist to generically call a local datetime func such that it 
renders as SYSDATE in Oracle and GETDATE() in SQL Server?

Thanks,
jlc

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/4f92c075-28b9-4c38-af10-5d21b8c83446n%40googlegroups.com.