Re: [sqlalchemy] Re: Using TextClause in with_expression

2018-06-26 Thread Mike Bayer
On Tue, Jun 26, 2018 at 8:09 AM, Eugene Prikazchikov wrote: > Traceback: > > Traceback (most recent call last): > File "1.py", line 15, in > s.query(A).options(with_expression(A.expr, text('x'))) > File > ".venv/lib/python3.6/site-packages/sqlalchemy/orm/strategy_options.py", line >

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

[sqlalchemy] When gets flagged as mutated with postgresql JSONB column?

2018-06-26 Thread Victor Reichert
Hi, I have a class like: class SQLClass(db): json_field = Column(sqlalchemy.dialects.postgresql.JSONB) I'm doing something like: session.add( SQLClass(json_field = dict( key = [value1] ) )) session.commit() slq_class_obj = session.query(SQLClass).first() new_dict =

Re: [sqlalchemy] When gets flagged as mutated with postgresql JSONB column?

2018-06-26 Thread Mike Bayer
On Tue, Jun 26, 2018 at 3:56 PM, Victor Reichert wrote: > Hi, > > I have a class like: > > class SQLClass(db): > > json_field = Column(sqlalchemy.dialects.postgresql.JSONB) > > I'm doing something like: > > session.add( > SQLClass(json_field = dict( > key = [value1] > ) > )) >

[sqlalchemy] from_statement NOW()

2018-06-26 Thread Danila Ganchar
I found strange behavior. I have a model: class User(Base): __tablename__ = 'test_user' id = Column(Integer, primary_key=True) timeout = Column(Integer) last_receive_time = Column(TIMESTAMP) I have a next script: # run several times session.add( User( timeout=1,

[sqlalchemy] Re: Using TextClause in with_expression

2018-06-26 Thread Eugene Prikazchikov
Traceback: Traceback (most recent call last): File "1.py", line 15, in s.query(A).options(with_expression(A.expr, text('x'))) File ".venv/lib/python3.6/site-packages/sqlalchemy/orm/strategy_options.py", line 1438, in with_expression False, {"expression": expression}) File

Re: [sqlalchemy] When gets flagged as mutated with postgresql JSONB column?

2018-06-26 Thread Victor Reichert
Thanks! I understand what was happening. I had tried MutableDict, but I think my data was too complex (a list-valued dictionary) for the basic implementation. When it didn't work I I got confused and thought reassigning the value would trigger mutation tracking. On Tuesday, June 26, 2018 at

[sqlalchemy] Using TextClause in with_expression

2018-06-26 Thread Eugene Prikazchikov
I am trying to use TextClause in with_expression and getting error. Simplest example: from sqlalchemy import * from sqlalchemy.orm import * from sqlalchemy.ext.declarative import declarative_base Base = declarative_base() class A(Base): __tablename__ = 'a' id = Column(Integer,