Reputation: 11
I am using postgresql db with sqlalchemy
When I use the query select now()
directly I get a result that can be converted into string, but I can't produce this output using sqlalchemy.
Already I have used the following module which is not giving me the result I needed
from sqlalchemy: import func
Upvotes: 1
Views: 706
Reputation: 127410
The func
module is a proxy that creates functions. So func.now()
will produce the column you want.
now = session.query(func.now()).scalar()
This returns a Python datetime object.
Upvotes: 3