I have a very simple table and query. For some reason it hangs after a few
executions and I have to restart the application.
Code to set it up:
from sqlalchemy import (
Column,
Integer,
String
)
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class User(Base):
__tablename__ = 'users'
id = Column(Integer, primary_key=True)
pname = Column(String)
from sqlalchemy import create_engine
engine = create_engine('mysql+mysqlconnector://user:pass@server/database',
echo=True)
Base.metadata.bind = engine
from sqlalchemy.orm import sessionmaker
Session = sessionmaker(bind=engine)
session = Session()
The query I run is simply
session.query(User).all()
System:
- Python 3.4.3
- The database is a remote MySQL Ver 5.5.41-0ubuntu0.14.04.1 running on
debian-linux-gnu on x86_64
- MySQL Connector/Python 2.0.3
- SQLAlchemy package: SQLAlchemy-1.0.5-py3.4.egg-info (I had the same
problem with a ver < 1.0 so I upgraded but no improvement)
- The clients are local, whether run on PC or Mac the problem is the same
Some observations:
- After I run the query a few times, the program hangs.
- If I uncomment the pname field, however, it seems like it will never
hang.
- If I replace .all() with .first() the program won't hang
- The general log on the MySQL server shows that the server receives the
query so the problem is likely on the receiving end of SQLAlchemy
- The server runs a Wordpress too which continues to function even if
the SQLAlchemy connection hangs
- echo True or False makes no difference
Any ideas about this very weird behahior?
Thanks
Dr.
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.