Re: [sqlalchemy] Re: from_statement NOW()

2018-07-05 Thread Danila Ganchar
First of all, thank you for your time and feedback. I really apologize for my inattention. The problem wasn't related with sqlalchemy or python/sql timezones. I run raw sql query using Pycharm + Database console . The results using

Re: [sqlalchemy] Re: from_statement NOW()

2018-06-29 Thread Mike Bayer
check that the timezones are matching up, e.g. that your python times aren't X hours off from the PG one, stuff like that On Fri, Jun 29, 2018 at 11:44 AM, Mike Bayer wrote: > you need to look at the SQL output and the results and additionally > log in to the psql command line and check

Re: [sqlalchemy] Re: from_statement NOW()

2018-06-29 Thread Mike Bayer
you need to look at the SQL output and the results and additionally log in to the psql command line and check individual elements of what you are doing. like what the current time is from now(), what are the rows in the table without any WHERE criterion, etc. On Fri, Jun 29, 2018 at 11:41 AM,

Re: [sqlalchemy] Re: from_statement NOW()

2018-06-29 Thread Danila Ganchar
Thank you for your feedback. I apologize for perseverance. I understand the difference between python now() and db now(). Why I didn't use *sleep() *in previous example? Because when I run the script again a few seconds has already passed. And I should see at least one or two record. I

Re: [sqlalchemy] Re: from_statement NOW()

2018-06-27 Thread Mike Bayer
I apologize for my inpatient tone in my previous email. I would hope that everyone in this mailing list feels welcome. On Wed, Jun 27, 2018, 10:59 AM Mike Bayer wrote: > this is a very simple issue to debug with basic programming > techniques, first off, put echo='debug' in your create_engine

Re: [sqlalchemy] Re: from_statement NOW()

2018-06-27 Thread Mike Bayer
this is a very simple issue to debug with basic programming techniques, first off, put echo='debug' in your create_engine so you can see all SQL and results: e = create_engine("postgresql://scott:tiger@localhost/test", echo='debug') next, if you are running over to a SQL command line vs.

Re: [sqlalchemy] Re: from_statement NOW()

2018-06-27 Thread Danila Ganchar
Ok. I ran the script 10 times on a clean table. Now I run raw sql: SELECT * FROM test_user WHERE (last_receive_time + INTERVAL '1 second' * timeout) < NOW(); The result: 10 records. Now I run script one more time. Still 0 records using from_statement. amount records using NOW() = 0 As I

Re: [sqlalchemy] Re: from_statement NOW()

2018-06-26 Thread Mike Bayer
definitely, triyng to match up python .now() with database .now() is not going to work, in particular since .now() in the database is often the transaction start time, not the actual time. On Tue, Jun 26, 2018 at 12:28 PM, Jonathan Vanasco wrote: > the difference is possibly because this is

[sqlalchemy] Re: from_statement NOW()

2018-06-26 Thread Jonathan Vanasco
the difference is possibly because this is calculated in Python, each time it is executed: datetime.datetime.now() this is calculated in Postgres, and refers to the beginning of the transaction; it does not change across the transaction. NOW() -- SQLAlchemy - The Python SQL Toolkit and