[sqlalchemy] Warning: Incorrect datetime value
I am constructing queries involving MSTimeStamp fields in MySQL and am being receiving Incorrect datetime value warnings even in situations where my queries are valid in MySQL. How do I modify the following query so that sqlalchemy will accept it without warning: session.query(MyClass.id).filter(MyClass.timestamp (func.now() - 2)).first() ? The generated sql is SELECT my_table.id AS my_table_id FROM my_table WHERE my_table.timestamp now() - %s LIMIT 0, 1 The warning I get is /usr/lib/pymodules/python2.5/sqlalchemy/engine/default.py:123: Warning: Incorrect datetime value: '20100209953011.00' for column 'timestamp' at row 1 cursor.execute(statement, parameters) Why is sqlalchemy even seeing the value '20100209953011.00', which is the outcome of the now() - 2 operation inside the query? I tried changing (func.now() - 2) to func.timestamp (func.now() - 2) but I still get the same warning. If I change 2 to 200, I don't get warned. Why would this be? It works with no warning if I change it to session.query(MyClass.id).filter(func.now() - MyClass.timestamp 2).first() , but that is not an acceptable solution because now MySQL can't use my index on MyClass.timestamp. I am using SQLA .5.5 -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] Warning: Incorrect datetime value
I am constructing queries involving MSTimeStamp fields in MySQL and am being receiving Incorrect datetime value warnings even in situations where my queries are valid in MySQL. How do I modify the following query so that sqlalchemy will accept it without warning: session.query(MyClass.id).filter(MyClass.timestamp (func.now() - 2)).first() ? The generated sql is SELECT my_table.id AS my_table_id FROM my_table WHERE my_table.timestamp now() - %s LIMIT 0, 1 The warning I get is /usr/lib/pymodules/python2.5/sqlalchemy/engine/default.py:123: Warning: Incorrect datetime value: '20100209953011.00' for column 'timestamp' at row 1 cursor.execute(statement, parameters) Why is sqlalchemy even seeing the value '20100209953011.00', which is the outcome of the now() - 2 operation inside the query? I tried changing (func.now() - 2) to func.timestamp (func.now() - 2) but I still get the same warning. If I change 2 to 200, I don't get warned. Why would this be? It works with no warning if I change it to session.query(MyClass.id).filter(func.now() - MyClass.timestamp 2).first() , but that is not an acceptable solution because now MySQL can't use my index on MyClass.timestamp. I am using SQLA .5.5 -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
Re: [sqlalchemy] Warning: Incorrect datetime value
On Feb 10, 2010, at 6:52 PM, Bobby Impollonia wrote: I am constructing queries involving MSTimeStamp fields in MySQL and am being receiving Incorrect datetime value warnings even in situations where my queries are valid in MySQL. How do I modify the following query so that sqlalchemy will accept it without warning: session.query(MyClass.id).filter(MyClass.timestamp (func.now() - 2)).first() ? The generated sql is SELECT my_table.id AS my_table_id FROM my_table WHERE my_table.timestamp now() - %s LIMIT 0, 1 The warning I get is /usr/lib/pymodules/python2.5/sqlalchemy/engine/default.py:123: Warning: Incorrect datetime value: '20100209953011.00' for column 'timestamp' at row 1 cursor.execute(statement, parameters) Why is sqlalchemy even seeing the value '20100209953011.00', which is the outcome of the now() - 2 operation inside the query? I tried changing (func.now() - 2) to func.timestamp (func.now() - 2) but I still get the same warning. If I change 2 to 200, I don't get warned. Why would this be? It works with no warning if I change it to session.query(MyClass.id).filter(func.now() - MyClass.timestamp 2).first() , but that is not an acceptable solution because now MySQL can't use my index on MyClass.timestamp. That warning is not generated by SQLAlchemy so it is not seeing it. MySQL-python is generating that warning. You'd have to consult the DBAPI's mailing list for help on this one since SQLA just passes your bound values straight through - I'm not familiar with what that 2 might mean in MySQL parlance, 2 seconds ? no clue. I am using SQLA .5.5 -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.