a ROLLBACK is occurring which suggests a different error has occurred
and is being swallowed - the transaction can then not continue. Does
your production environment have logs which would illustrate other
exceptions and reasons for rollbacks prior to this one? It is possible
that something like autoflush on query is causing a flush to fail,
something lime that.
On 03/06/2017 08:03 AM, karl.latti...@innolabs.uk wrote:
Hi, I'm having some trouble with sqlalchemy and timestamps
I have a schema which looks like this
class MyTable(Entity):
__tablename__ = "MyTable"
id = Column(Integer, primary_key=True)
tstamp = Column(DateTime, nullable=False)
when I run a query such as
current_time = datetime.datetime.utcnow()
s = current_time - datetime.timedelta(hours=1)
hour_ago = s.isoformat()
query = session.query(func.count(MyTable)).filter(MyTable > hour_ago)
I will get the following StatementError - but not on my local testing
(mac os sierra) system, only when testing the system on our live docker
based system (Ubuntu:wily)
Has anyone come across this issue before? I've tried using a date time
object but that resulted to the same problem so I opted to change to the
iso string. It seems that the timestamp is simply not being passed to
the query statement in the parameters.
StatementError: (sqlalchemy.exc.InvalidRequestError) Can't reconnect
until invalid transaction is rolled back [SQL: u'SELECT
count(`MyTable`.id) AS count_1 \nFROM `MyTable` \nWHERE `MyTable`.tstamp
%s'] [parameters: [
{}
]]
Any help would be much appreciated.
Regards,
K,
--
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
<mailto:sqlalchemy+unsubscr...@googlegroups.com>.
To post to this group, send email to sqlalchemy@googlegroups.com
<mailto:sqlalchemy@googlegroups.com>.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.
--
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 post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.